fix: planner GIT_RANGE newline bug from pipefail + head -1

set -o pipefail causes head -1 to fail the pipeline when git log
is still producing output. The || fallback then appends a second
line. Fix: capture first SHA separately with || true.
This commit is contained in:
openhands 2026-03-15 12:41:50 +00:00
parent 1a9afa9f9c
commit efa6eab352

View file

@ -40,11 +40,15 @@ if [ -f "$MARKER_FILE" ]; then
GIT_RANGE="${LAST_SHA}..HEAD"
else
log "WARNING: marker SHA ${LAST_SHA:0:7} not found, using 30-day window"
GIT_RANGE="$(git log --format=%H --after='30 days ago' --reverse | head -1 2>/dev/null || echo HEAD~30)..HEAD"
local first_sha
first_sha=$(git log --format=%H --after='30 days ago' --reverse 2>/dev/null | head -1) || true
GIT_RANGE="${first_sha:-HEAD~30}..HEAD"
fi
else
log "No marker file, using 30-day window"
GIT_RANGE="$(git log --format=%H --after='30 days ago' --reverse | head -1 2>/dev/null || echo HEAD~30)..HEAD"
local first_sha
first_sha=$(git log --format=%H --after='30 days ago' --reverse 2>/dev/null | head -1) || true
GIT_RANGE="${first_sha:-HEAD~30}..HEAD"
fi
GIT_LOG=$(git log "$GIT_RANGE" --oneline --no-merges 2>/dev/null || true)