Skip to content

Skip git plugin gracefully when the repo has no remotes#388

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
oliver/replace-error-log-with-warn-when-git-repo-has-no-remotes-yet
May 22, 2026
Merged

Skip git plugin gracefully when the repo has no remotes#388
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
oliver/replace-error-log-with-warn-when-git-repo-has-no-remotes-yet

Conversation

@oliverli
Copy link
Copy Markdown
Collaborator

@oliverli oliverli commented May 22, 2026

Summary

  • For a freshly-initialized local repository that has not yet been pushed to a remote, the git plugin previously logged an error-level line — Could not get git information: No git remotes available — and discarded all collected git info (hash, branch, message, tracked files) because gitRemote() threw inside getRepositoryData()'s Promise.all.
  • The empty-remotes case is now detected up front in processGit(). The plugin logs a clear warn (No git remotes available, skipping git plugin. This is expected for a repository that has not been pushed yet.) and returns, mirroring the existing "no .git directory" pattern at packages/plugins/git/src/index.ts.
  • The defensive throw new Error('No git remotes available') in gitRemote() is preserved so direct callers of the helper still get the strict contract.
  • Build behavior is unchanged — this was already non-blocking; the log line is just downgraded from error to warn and worded for the expected case.

Test plan

  • yarn typecheck:all
  • yarn lint packages/plugins/git/src/*.ts
  • yarn test:unit packages/plugins/git — 3 suites, 32 tests pass, including a new gitRemote no-remotes unit test and a new No remotes integration describe asserting getRepositoryData is not called, the git hook does not fire, and context.git stays undefined across all bundlers.
  • Manual repro in a scratch directory: git init && git add . && git commit -m init (no git remote add), then run a build with this plugin configured. Expect a single warn-level line instead of the previous error-level one.

🤖 Generated with Claude Opus 4.7 (1M context)

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@oliverli oliverli changed the title Replace error log with warn when git repo has no remotes yet Skip git plugin gracefully when the repo has no remotes May 22, 2026
@oliverli oliverli marked this pull request as ready for review May 22, 2026 19:26
@oliverli oliverli requested a review from yoannmoinet as a code owner May 22, 2026 19:26
@datadog-prod-us1-4
Copy link
Copy Markdown

datadog-prod-us1-4 Bot commented May 22, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 90b2251 | Docs | Datadog PR Page | Give us feedback!

For a freshly-initialized local repository that hasn't been pushed yet,
the git plugin used to emit an error-level line and discard all
collected git info because gitRemote() threw inside getRepositoryData()'s
Promise.all. Detect the empty-remotes case up front in processGit() and
log a clear warn + return, matching the existing "no .git directory"
pattern. The defensive throw in gitRemote() is kept for direct callers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oliverli oliverli force-pushed the oliver/replace-error-log-with-warn-when-git-repo-has-no-remotes-yet branch from 38ac2dc to 90b2251 Compare May 22, 2026 19:35
Copy link
Copy Markdown
Member

@yoannmoinet yoannmoinet left a comment

Choose a reason for hiding this comment

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

LGTM

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 41496a0 into master May 22, 2026
6 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the oliver/replace-error-log-with-warn-when-git-repo-has-no-remotes-yet branch May 22, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants