Repository navigation
Conversation
GitLab issues routable tokens as <prefix><base64-payload>.<token-version>.<payload-length><crc32> which is what both gitlab.com and self-managed instances hand out today. The bridge only matched the legacy shape of an optional "glpat-" prefix followed by exactly 20 base62 characters, so every current token was rejected by the format check in promptToken. Accept both shapes via a validTokenFormat helper, and cover them with table driven tests. The API call in promptToken still decides whether a token actually works, this only catches typos early. Fixes git-bug#1587
'git-bug version' prints '<name> <version> [commit[/dirty]] <compiler> <platform> <arch>', which is fine to read but not to embed: a statusline or a version comparison has to strip the prefix and every metadata field itself. git-bug#1528 asks for the git-annex style form, where 'version --raw' prints just the number. The raw value is cut from the same string the default output prints, so the two forms cannot drift apart, and the default output is unchanged. Closes git-bug#1528
Man-page generation strips <version>, which left "print alone". Spell it as "the version string" and regenerate the man/md mirrors.
Author
|
Addressed the greptile note: the |
This branch has not been deployed
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.
What
Add a
--rawflag togit-bug version, which currently prints:--rawprints just the version, on a line of its own:This is #1528, in the shape
git-annex version --rawestablished: one bare version string that can be embedded in a statusline, a package script, or a version comparison without the caller having to strip a prefix and every metadata field.Closes #1528.
Why this shape
The raw value is cut from the same string the default output prints (
strings.Cut(full, " ")), rather than read from a second place.<version>is documented as the first space-separated field, so the two forms cannot drift apart, and there is no new code path deciding what the version "really" is.--rawalso emits a trailing newline, unlike the current output which ends without one. That is what makes$(git-bug version --raw)behave, and it is the only difference the flag introduces beyond the field itself.The default output is byte-for-byte unchanged —
TestVersionCommandDefaultUnchangedasserts that against the full documented string, so the flag cannot regress anything that parses the existing form.Tests
commands/version_test.go, new:TestRawVersion— table over the shapesgetVersion()can produce: bare version, version + commit,commit/dirty, theundefined (no build info)fallback, the full documented shape, and the empty string. It pins the first-field rule rather than a single example.TestVersionCommandRaw— runs the command and asserts the exact stdout,v1.2.3\n.TestVersionCommandDefaultUnchanged— runs the command without the flag and asserts the pre-existing output.Built and run locally:
Generated files
doc/md/git-bug_version.mdanddoc/man/git-bug-version.1are regenerated withgo generate, which the CI jobCheck generated files are up to dateverifies. Shell completions are unchanged (cobra emits flag names dynamically).I did not include the
api/graphql/graph/repository.generated.godrift thatgo generate ./...also produced; it is unrelated to this change and is a separate question.Notes
/dirtyand commit-hash discussion in feat: add --raw to version #1528 alone — those fields are already in the default output and--rawsimply omits them, which is the point of the flag.
Confidence Score: 5/5
The PR appears safe to merge; the previous finding is fixed and no new actionable issues were found.Summary
Adds
--rawtogit-bug versionto print only the version string with a trailing newline.git-bug version --rawprints the version alone on its own line.Reviews (2) · Last reviewed commit: "docs(version): avoid angle brackets in t..." · Reviewed by Greptile