Merge pull request 'fix: bug: dev-agent.sh line 272 — grep -c ... || echo 0 produces "0\n0" and breaks arithmetic (#574)' (#611) from fix/issue-574 into main
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
This commit is contained in:
commit
dbf1340027
2 changed files with 6 additions and 2 deletions
|
|
@ -268,7 +268,10 @@ log "forge remote: ${FORGE_REMOTE}"
|
||||||
# First attempt: fix/issue-N, subsequent: fix/issue-N-1, fix/issue-N-2, etc.
|
# First attempt: fix/issue-N, subsequent: fix/issue-N-1, fix/issue-N-2, etc.
|
||||||
if [ "$RECOVERY_MODE" = false ]; then
|
if [ "$RECOVERY_MODE" = false ]; then
|
||||||
# Count only branches matching fix/issue-N, fix/issue-N-1, fix/issue-N-2, etc. (exact prefix match)
|
# Count only branches matching fix/issue-N, fix/issue-N-1, fix/issue-N-2, etc. (exact prefix match)
|
||||||
ATTEMPT=$(git ls-remote --heads "$FORGE_REMOTE" "refs/heads/fix/issue-${ISSUE}" 2>/dev/null | grep -c "refs/heads/fix/issue-${ISSUE}$" || echo 0)
|
# grep -c always prints a count and exits 1 when count=0; use || true to swallow the exit status.
|
||||||
|
# Do NOT use "|| echo 0" here: grep would print "0" AND echo would append "0", producing "0\n0" which breaks arithmetic.
|
||||||
|
ATTEMPT=$(git ls-remote --heads "$FORGE_REMOTE" "refs/heads/fix/issue-${ISSUE}" 2>/dev/null | grep -c "refs/heads/fix/issue-${ISSUE}$" || true)
|
||||||
|
ATTEMPT="${ATTEMPT:-0}"
|
||||||
ATTEMPT=$((ATTEMPT + $(git ls-remote --heads "$FORGE_REMOTE" "refs/heads/fix/issue-${ISSUE}-*" 2>/dev/null | wc -l)))
|
ATTEMPT=$((ATTEMPT + $(git ls-remote --heads "$FORGE_REMOTE" "refs/heads/fix/issue-${ISSUE}-*" 2>/dev/null | wc -l)))
|
||||||
if [ "$ATTEMPT" -gt 0 ]; then
|
if [ "$ATTEMPT" -gt 0 ]; then
|
||||||
BRANCH="fix/issue-${ISSUE}-${ATTEMPT}"
|
BRANCH="fix/issue-${ISSUE}-${ATTEMPT}"
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,8 @@ PAGES=$(printf '%s\n' "$PARSED" | jq -c '
|
||||||
')
|
')
|
||||||
|
|
||||||
TOTAL_REQUESTS=$(printf '%s\n' "$PARSED" | wc -l | tr -d ' ')
|
TOTAL_REQUESTS=$(printf '%s\n' "$PARSED" | wc -l | tr -d ' ')
|
||||||
PAGE_VIEWS=$(printf '%s\n' "$PAGES" | grep -c . || echo 0)
|
PAGE_VIEWS=$(printf '%s\n' "$PAGES" | grep -c . || true)
|
||||||
|
PAGE_VIEWS="${PAGE_VIEWS:-0}"
|
||||||
UNIQUE_VISITORS=$(printf '%s\n' "$PAGES" | jq -r '.ip' | sort -u | wc -l | tr -d ' ')
|
UNIQUE_VISITORS=$(printf '%s\n' "$PAGES" | jq -r '.ip' | sort -u | wc -l | tr -d ' ')
|
||||||
|
|
||||||
# Top pages by hit count
|
# Top pages by hit count
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue