Handle detached HEAD and invalid remote URL; add tests to improve coverage - #42
Merged
zhaochunqi merged 1 commit intoApr 15, 2026
Merged
Conversation
Owner
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
==========================================
+ Coverage 96.10% 97.46% +1.36%
==========================================
Files 5 5
Lines 154 158 +4
==========================================
+ Hits 148 154 +6
+ Misses 5 2 -3
- Partials 1 2 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Motivation
HEADas an error instead of returningHEADas a branch name.convertToWebURLearly.Description
getBranchName(incmd/git.go) to return a clear error whenrepo.Head()points to a non-branch (detached HEAD) and fall back to reference lookup only if necessary.rootCmd.RunE(incmd/root.go) to return an error whenconvertToWebURL(remoteURL)yields an empty string.cmd/git_additional_test.gowithTest_getBranchName_DetachedHEADto cover the detached-HEAD path forgetBranchName.cmd/root_additional_test.gowithTest_rootCmd_InvalidRemoteURLFormatto assertrootCmd.RunEerrors on unsupported remote URL formats.Testing
go test ./... -coverprofile=coverage.out, but the Go toolchain is not available in this environment (go: command not found).gofmt -won modified files, butgofmtis not available in this environment (gofmt: command not found).cmd/git_additional_test.go,cmd/root_additional_test.go) and exercise the new code paths, but they were not executed here due to the missing Go toolchain.Codex Task