Bug: gogit checkout robustness: remotes[0] panic, wrong error message, empty version output, non-idempotent 0444 writes
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start by reading cmd/checkout.go around the quoted lines: the remote lookup at line 100, the --pr error at line 151, the version assignment block at 108-155 and the two os.WriteFile calls at 159 and 167. Check whether existing tests under cmd/ cover checkout, and add cases for an empty remotes/URLs config, the PR error text, no branch flag, and re-running against an existing output file. Done when all four paths return a message or file instead of panicking, misreporting or failing on re-run.
Written by the indexing model from the issue text.
Description
Description
A group of robustness problems in cmd/checkout.go (master 198a18f):
1. Potential index-out-of-range panics — line 100:
remoteURL := remotes[0].Config().URLs[0]
remotes can be empty for a locally-created .git (no remote configured), and URLs can be empty in a broken config; both panic instead of producing an error message.
2. Wrong variable in the PR checkout error — line 151:
err = fmt.Errorf("unable to checkout git branch: %s, error: %v", o.tag, err)
This is the --pr path but the message prints o.tag. It should report pr-%d.
3. Empty --version-output — version is only set when --branch/--tag/--pr is given (lines 108–155). With none of them set, line 159 happily writes an empty file, which downstream builds then consume as an empty version. It should either default to the checked-out branch/HEAD or fail explicitly.
4. Non-idempotent output files — lines 159 and 167 write with mode 0444:
err = os.WriteFile(o.versionOutput, ..., 0444)
On a re-run (same workspace, e.g. a retried CI step) the write fails with permission denied because the previous file is read-only and owned by the same user. 0644 (or remove-then-write) keeps re-runs working.
Each item is small and independently testable; happy to split into separate PRs if preferred.
- Dominant language
- Go
- Stars
- 19
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LinuxSuRen/gogit
-
Docs: replace the real-looking access token in README examples and fix build status help textsPossibly taken @linuxsuren-fs claimed this 6 days ago. Opendocumentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 88/100
LinuxSuRen/gogit#90 ·
-
Bug: --token file://… content is not trimmed, trailing newline breaks authenticationPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
LinuxSuRen/gogit#87 ·
-
Bug: gogit checkout fails on repositories whose default branch is not masterPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
LinuxSuRen/gogit#85 ·
-
Bug: DingTalk notification builds JSON by string concatenation, echoes the token, leaks resp.Body and swallows errorsPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
LinuxSuRen/gogit#84 ·
-
Security: git access token is printed into pod logs by the Argo Workflows executorPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
LinuxSuRen/gogit#83 ·
All issues in LinuxSuRen/gogit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
aminueza/terraform-provider-minio#1406 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
kubernetes/kubeadm#3339 ·
-
A failed hydrate call can be dropped when the row's wait is ready tooPossibly taken @turbot-agent-fleet claimed this today. Openagent:ready
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
turbot/steampipe-plugin-sdk#1018 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day
-
enhancement needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day