Skip to content

feat(ci): add not-in-git-repo guard to ci:run and ci:rerun (W-23597902, #1761) - #3843

Open
heroku-johnny wants to merge 3 commits into
mainfrom
W-23597902
Open

feat(ci): add not-in-git-repo guard to ci:run and ci:rerun (W-23597902, #1761)#3843
heroku-johnny wants to merge 3 commits into
mainfrom
W-23597902

Conversation

@heroku-johnny

Copy link
Copy Markdown
Contributor

Summary

  • Adds an early gitService.inGitRepo() guard to ci:run and ci:rerun that throws a clear, user-friendly error when run outside a git repository
  • Previously, running these commands outside a git repo would silently fail deep inside createSourceBlob() with a confusing error; now the user sees: "Not in a git repository. ci:rerun must be run from within your app's git repo."
  • Uses the existing gitService singleton (already imported in ci:run; newly imported in ci:rerun) so the guard is stubbable in tests
  • Adds a when not in a git repository test case to both ci:run and ci:rerun unit tests
  • Stubs gitService.inGitRepo to true in the existing happy-path tests to keep them isolated

Test plan

  • ci:run — new test case when not in a git repository passes
  • ci:rerun — new test case when not in a git repository passes
  • All existing ci:run and ci:rerun tests continue to pass
  • npm run lint reports no errors for touched files
  • Manually run heroku ci:run --pipeline=foo outside a git repo and confirm the error message

Closes #1761 | GUS W-23597902

🤖 Generated with Claude Code

Adds an early inGitRepo() check to ci:run and ci:rerun that throws a
clear error message when run outside a git repository, preventing
confusing failures from createSourceBlob() silently swallowing git
errors.

Closes #1761 (W-23597902)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@heroku-johnny
heroku-johnny requested a review from a team as a code owner July 27, 2026 20:13

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@heroku-johnny I think these messages would need CX review since it's new user facing text?

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some comments on additional reviews that might be needed. Otherwise, testing passes. LGTM

Comment thread src/commands/ci/rerun.ts
const {args, flags} = await this.parse(CiReRun)

if (!gitService.inGitRepo()) {
this.error('Not in a git repository. ci:rerun must be run from within your app\'s git repo.')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIRC, new user facing text like this and those below should be CX reviewed prior to merge.

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.

ci:rerun should fail if executed outside of a git repo

2 participants