feat: Report shallow clones and print errors in plain text - #214
Merged
Conversation
Three findings from the analysis of #213, none of which depend on the feature discussion there. The README claimed that output is printed in a human-readable format by default, which has been wrong since 2022 and caused the misunderstanding in the issue. It also never documented that the next version is computed relative to the last release reachable from HEAD, which is the root of the surprises that drive users to write defensive validation steps. A shallow clone, by far the most common misconfiguration, failed with "object not found". It now reports what is actually wrong and how to fix it, but only when no release tag was found within the truncated history, so a shallow clone that still contains the base tag keeps working. zerolog did not do any logging in this project: all six call sites were Fatal, and there was no Info, Warn or Debug at all. In CI it turned every error into an unreadable JSON line, and main.go swallowed the actual cause and appended a second, meaningless message to the one cobra had already printed. Errors now go through cobra, which removes both problems, and zerolog and go-isatty are no longer needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014zcGUq3NUnFpU1mRWkyBpU
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.
Refers to #213
While analyzing #213 three findings turned up that are worth fixing independently of the feature discussion in that issue. The warnings,
--baseand--strictideas discussed there are deliberately not part of this PR.The README described behavior that does not exist
The claim "By default, output will be printed to the console in a human-readable format" has been wrong since 2022 — the default target
versionprints a bare version string. This is exactly what led the reporter of #213 to assume atarget=human-readableexists.The README also never documented that the next version is computed relative to the last release reachable from
HEAD, rather than the highest tag in the repository. That is the root cause of the surprises which drive users to write defensive validation steps in their workflows. There is now a section How the next version is determined that spells this out, including the case where the result can be lower than the latest release.Shallow clones now say what is wrong
A missing
fetch-depth: 0is by far the most common misconfiguration, and it failed withobject not found.The check deliberately only fires when no release tag was found within the truncated history. A shallow clone that still contains the base tag produces a correct result today and keeps working — verified against a real clone:
object not foundErrors are readable again
zerolog was not doing any logging here: all six call sites were
Fatal, with noInfo,WarnorDebuganywhere. In CI it turned every error into{"level":"fatal",...}— precisely where the new message above needs to be readable. On top of that,main.goswallowed the actual cause and appended a second, meaningless line to the message cobra had already printed:Errors now go through cobra's own mechanism (
RunE+SilenceUsage), which removes both problems. As a side effectzerologandgo-isattyare no longer needed as dependencies. An invalid target now also names the valid ones.Observable behavior
Intended
object not foundWorth knowing
"level":"fatal"would break — unlikely, but it is a change.--target versionandjsonstill write nothing but the version resp. the JSON object to stdout, errors go to stderr only.1on all error paths.Verification
makepasses. Beyond that, verified against real clones of this repository:New tests cover
IsShallowand all three rows of the table above.🤖 Generated with Claude Code
https://claude.ai/code/session_014zcGUq3NUnFpU1mRWkyBpU