Skip git plugin gracefully when the repo has no remotes#388
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intoMay 22, 2026
Conversation
🎉 All green!🧪 All tests passed 🔗 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>
38ac2dc to
90b2251
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
error-level line —Could not get git information: No git remotes available— and discarded all collected git info (hash, branch, message, tracked files) becausegitRemote()threw insidegetRepositoryData()'sPromise.all.processGit(). The plugin logs a clearwarn(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.gitdirectory" pattern atpackages/plugins/git/src/index.ts.throw new Error('No git remotes available')ingitRemote()is preserved so direct callers of the helper still get the strict contract.errortowarnand worded for the expected case.Test plan
yarn typecheck:allyarn lint packages/plugins/git/src/*.tsyarn test:unit packages/plugins/git— 3 suites, 32 tests pass, including a newgitRemoteno-remotes unit test and a newNo remotesintegration describe assertinggetRepositoryDatais not called, thegithook does not fire, andcontext.gitstaysundefinedacross all bundlers.git init && git add . && git commit -m init(nogit remote add), then run a build with this plugin configured. Expect a singlewarn-level line instead of the previouserror-level one.🤖 Generated with Claude Opus 4.7 (1M context)