refactor: use Go native build info for commit and date#47
Merged
Conversation
Replace ldflags injection of commit and date with runtime/debug.ReadBuildInfo(), which Go embeds automatically from VCS. Only version remains as an ldflag since there is no native way to get the git tag at runtime. This aligns the build pattern across all three CLIs (esq, atl, n8nctl).
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the CLI to dynamically retrieve VCS information (commit hash and build date) using the runtime/debug package instead of relying on ldflags during the build process. The BuildInfo struct has been removed, and a new vcsInfo function extracts metadata directly from the binary's build information. Feedback was provided to enhance the vcsInfo function by checking the vcs.modified flag to indicate whether the binary was built from a 'dirty' repository state.
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
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
commitanddatewithruntime/debug.ReadBuildInfo()which Go embeds automatically from VCSBuildInfostruct — version is now passed as a string, commit/date derived fromruntime/debugversionremains as an ldflag (no native way to get the git tag at runtime)-X main.version={{.Version}}Test plan
go vet ./...passesgo test ./...passes (all existing tests unaffected)-s -wstripping does NOT affectruntime/debugbuild info