Skip to content

CI: scaffold identity via GIT_AUTHOR_*/GIT_COMMITTER_* env, never git config --global - #11

Merged
brettheap merged 4 commits into
mainfrom
fix/ci-identity-per-invocation
Sep 3, 2026
Merged

brettheap merged 4 commits into
mainfrom
fix/ci-identity-per-invocation

Conversation

@brettheap

@brettheap brettheap commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Lane: repo-shape

Two agents of this lane mirrored the CI step's git config --global user.* lines on the workstation on 2026-09-03 and rewrote the operator's ~/.gitconfig, changing the author of another lane's in-flight commits. The tooling (scaffold, adopt, update-shape, test fixtures) already takes identity per invocation from GIT_AUTHOR_/GIT_COMMITTER_; the workflow now sets those into $GITHUB_ENV instead, so nothing in this repository writes global git config anywhere. Verified: grep -rn 'config --global' over yml/py/sh finds nothing.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

Summary by Sourcery

Use per-invocation Git identity throughout shape scaffolding and CI without writing global Git configuration.

Bug Fixes:

  • Prevent CI and local lane tooling from modifying the operator’s global Git configuration by using per-invocation author and committer environment variables.

Enhancements:

  • Prefer GIT_AUTHOR_NAME when determining the shape elector while retaining configured identity as a fallback.

CI:

  • Set scaffolded commit identity through GitHub Actions environment variables instead of global Git configuration.

Tests:

  • Update the no-elector end-to-end fixture to clear per-invocation identity variables so it continues to exercise the intended refusal path.

…v, never `git config --global`

A lane mirroring the CI step on a workstation rewrote the operator's
~/.gitconfig on 2026-09-03 and changed the author of another lane's
in-flight commits. The scaffold, adopt, update-shape and the test
fixtures already take identity per invocation from these variables; the
workflow now does the same, so nothing in this repository writes global
git config anywhere.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Copilot AI lite review requested due to automatic review settings September 3, 2026 20:00
@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The CI workflow now exports Git author and committer identity through $GITHUB_ENV instead of running git config --global, preventing mirrored CI commands from modifying an operator’s global Git configuration while preserving identity for scaffolded commits and test fixtures.

File-Level Changes

Change Details Files
Replace global Git identity configuration with per-invocation environment variables for CI-created commits.
  • Write author and committer name/email variables to GitHub Actions’ environment file.
  • Update the workflow step name and comments to document the safety requirement and supported tooling.
.github/workflows/tests.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the environment variables are not honored by every scaffolded Git invocation, generated commits could receive the wrong author or committer identity, which persists in repository history. Reverting stops the behavior, and the affected commits can be regenerated or rewritten, so the impact is bounded and repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

With no global git config on the CI runner (the previous commit stopped
writing one), setup.sh and scaffold-project.py refused for want of an
elector. Per-invocation identity is now the first fallback, the config
the second, so a workstation with no ~/.gitconfig user and a runner with
only GIT_AUTHOR_* behave the same.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The workflow change correctly scopes Git identity to the job environment and removes the risky global gitconfig mutation, with only a minor PR-description consistency nit noted.

Pull request overview

Updates the CI test workflow to set Git author/committer identity via environment variables (GIT_AUTHOR_/GIT_COMMITTER_) instead of writing to global Git configuration, preventing accidental modification of an operator’s ~/.gitconfig when steps are mirrored locally.

Changes:

  • Replace git config --global user.* usage with $GITHUB_ENV exports of GIT_AUTHOR_* / GIT_COMMITTER_*.
  • Add explanatory workflow comments documenting why global Git config must not be used in CI.
File summaries
File Description
.github/workflows/tests.yml Switch CI Git identity setup from global gitconfig writes to per-job environment variables.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +44 to +47
# Per-invocation identity, never `git config --global`: a lane that
# mirrors this step on a workstation must not be able to rewrite the
# operator's ~/.gitconfig (it happened on 2026-09-03). The scaffold,
# adopt, update-shape and the test fixtures all honour these variables.
Copilot AI review requested due to automatic review settings September 3, 2026 20:02
…MITTER_NAME

The per-invocation identity is an elector now, so the negative path is
reachable only with both the env and the config suppressed.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

setup.sh still prefers gh api user before GIT_AUTHOR_NAME, which can override the intended per-invocation identity and undermines the PR’s stated behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread setup.sh
Comment on lines 268 to 275
if [ -z "$ELECTED_BY" ] && [ "$LOCAL_MODE" -ne 1 ]; then
ELECTED_BY="$(gh api user --jq .login 2>/dev/null || true)"
fi
if [ -z "$ELECTED_BY" ]; then
ELECTED_BY="$(git config user.name 2>/dev/null || true)"
# Per-invocation identity first (GIT_AUTHOR_NAME), then the repo/global
# config, then the gh login — never a global config WRITE.
ELECTED_BY="${GIT_AUTHOR_NAME:-$(git config user.name 2>/dev/null || true)}"
fi
Comment thread scaffold-project.py
Comment on lines +393 to +395
# Per-invocation identity first, then the config — never a global
# config write (see the CI workflow note, 2026-09-03).
elected_by = (os.environ.get("GIT_AUTHOR_NAME") or "").strip() or git_out(["config", "user.name"], cwd=SHAPE_ROOT)
Copilot AI review requested due to automatic review settings September 3, 2026 20:05
@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

setup.sh currently fetches the gh login before checking GIT_AUTHOR_NAME, which prevents env override and contradicts the documented selection order.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

setup.sh:272

  • The elector selection order here doesn’t match the comment, and it also means GIT_AUTHOR_NAME won’t be honored whenever gh api user succeeds (because the gh login is fetched first). If the intent is “per-invocation env first, then git config, then gh login”, reorder the blocks accordingly so env can override and the comment stays accurate.
if [ -z "$ELECTED_BY" ] && [ "$LOCAL_MODE" -ne 1 ]; then
	ELECTED_BY="$(gh api user --jq .login 2>/dev/null || true)"
fi
if [ -z "$ELECTED_BY" ]; then
	# Per-invocation identity first (GIT_AUTHOR_NAME), then the repo/global
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +156 to +160
# `env` is an OVERRIDE map merged over the process environment by
# run_script, and the fixtures set GIT_AUTHOR_NAME there; the scaffold
# takes that per-invocation identity as an elector before the config, so
# the no-elector path is reachable only with BOTH blanked (empty string
# falls through to the config, which is /dev/null here).
@brettheap
brettheap merged commit 6232412 into main Sep 3, 2026
3 checks passed
@brettheap
brettheap deleted the fix/ci-identity-per-invocation branch September 11, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants