diff --git a/scripts/dev-lead-fix-reviews.sh b/scripts/dev-lead-fix-reviews.sh index a3d6f38c8..755f1caaf 100755 --- a/scripts/dev-lead-fix-reviews.sh +++ b/scripts/dev-lead-fix-reviews.sh @@ -30,6 +30,7 @@ fi # Checkout the PR branch for modification (Requirement 1) if [ "${DEV_LEAD_DRY_RUN:-false}" = "false" ] && [ -n "${PR_NUMBER:-}" ]; then gh pr checkout "$PR_NUMBER" --repo "$REPO" + setup_git_identity fi build_and_run() { @@ -375,6 +376,9 @@ commit_and_push() { # before committing or commit fails with "fatal: empty ident name". setup_git_identity git add -A + # Ensure git identity is set — actions/checkout only sets local config for the + # repo it checks out (.github-private), not for target repos cloned separately. + setup_git_identity # Explicit exit on failure: set -e is suspended when commit_and_push is called from # an if-statement condition, so git commit failures would be silently swallowed # otherwise. Using exit (not return) ensures CI fails visibly instead of posting a diff --git a/scripts/lib/git-identity.sh b/scripts/lib/git-identity.sh index a8f985711..b47af5b70 100644 --- a/scripts/lib/git-identity.sh +++ b/scripts/lib/git-identity.sh @@ -15,6 +15,9 @@ # setup_git_identity — configure git user.name/user.email for the bot user. # +# GitHub-hosted runners lack git identity by default; this helper ensures +# commits succeed whether we're committing to the primary repo or secondary checkouts. +# # BOT_USER env var (default: donpetry-bot) determines the identity. The # canonical noreply form (+@users.noreply.github.com) is preferred # because it links commits to the bot's GitHub profile; fall back to the @@ -23,7 +26,7 @@ setup_git_identity() { local bot="${BOT_USER:-donpetry-bot}" local bot_id bot_id=$(gh api "users/${bot}" --jq '.id' 2>/dev/null || echo "") - if [ -n "$bot_id" ]; then + if [[ -n $bot_id ]]; then git config user.email "${bot_id}+${bot}@users.noreply.github.com" else git config user.email "${bot}@users.noreply.github.com"