feat: retrieve git metadata from local repo#12
Merged
Conversation
alexanderbsingh
commented
Jul 7, 2026
Contributor
- Adds a flag to automatically get git metadata
- Adds an option to set a custom path to get the git metadata from
…a, and simplify environment variable parsing
…ection - Added `--git-repo-path` flag for custom repository path during Git metadata auto-detection. - Enhanced automatic Git metadata detection to log discovered metadata. - Updated README with usage details for `--git-repo-path`. - Improved tests to verify `--git-repo-path` functionality.
- Replaced manual shell-based Git metadata extraction with go-git library. - Enhanced error handling for Git discovery process. - Updated tests to reflect changes in Git metadata handling. - Adjusted dependencies in `go.mod` and `go.sum`.
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in mechanism to populate Git-related upload metadata (branch, commit SHA, origin) by querying a local Git repository, along with documentation and tests to validate the behavior.
Changes:
- Adds
--enable-auto-git-metadata(andBIFROST_ENABLE_AUTO_GIT_METADATA) plus--git-repo-pathto support auto-discovery of Git metadata. - Implements Git metadata discovery via
git -C <dir> ...and fills only missing metadata fields. - Updates README usage/examples and extends CLI tests to cover auto-discovery scenarios.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents manual vs. automatic Git metadata, new flags/env var, and updates the options table. |
| internal/bifrost/sbom_upload.go | Hooks auto-discovery into SBOM upload task creation; prints auto-detected metadata and a missing-metadata hint. |
| internal/bifrost/options.go | Adds new options/flags and reads BIFROST_ENABLE_AUTO_GIT_METADATA during validation. |
| internal/bifrost/git_metadata.go | New helper to discover Git metadata by executing Git commands in a target repo directory. |
| internal/bifrost/cli_test.go | Adds extensive coverage for auto Git metadata behavior and introduces stderr-capture + git repo helpers. |
| internal/bifrost/api.go | Formatting-only change (field alignment). |
| go.mod | Formatting-only change (closing paren alignment). |
| go.sum | Formatting-only change (line indentation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Deleted tests related to deprecated auto Git metadata functionality. - Simplified remaining tests to align with updated metadata handling.
konrader
approved these changes
Jul 8, 2026
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.