Bug: gogit checkout fails on repositories whose default branch is not master
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 85/100
Direzione di ricerca
Inizia in cmd/checkout.go: il valore predefinito del flag --branch è impostato vicino alla riga 46 e il git.CloneOptions con ReferenceName viene costruito intorno alla riga 82, dove c.Flags().Changed("branch") è già usato più avanti. Vincola ReferenceName a quello stesso controllo in modo che non venga inviato alcun ref di branch quando il flag è stato lasciato com'è, mantenendo invariato il percorso del branch esplicito. Fatto significa che gogit checkout su un repo con un branch predefinito main esegue il clone correttamente, e i test di checkout esistenti continuano a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
gogit checkout always clones with a hardcoded master reference — cmd/checkout.go:82:
if repo, err = git.PlainCloneContext(c.Context(), repoDir, false, &git.CloneOptions{
...
ReferenceName: plumbing.NewBranchReferenceName(o.branch), // o.branch defaults to "master"
with the flag default --branch master (line 46). For any repository whose default branch is not master (e.g. main, which is the GitHub default since 2020), the clone fails with:
failed to clone git repository '<url>' into '<dir>', error: couldn't find remote ref "refs/heads/master"
even though the user never asked for master.
How to reproduce
gogit checkout --url https://github.com/<any org with main default branch>/<repo> --target /tmp/repo
Suggested fix
When --branch was not explicitly set, clone without ReferenceName (go-git then checks out the remote HEAD / default branch), and only pass it when the user provided a branch. c.Flags().Changed("branch") is already used later in the function, so the same signal is available.
Expected behavior
gogit checkout should work on any repository regardless of its default branch name.
- Lingua principale
- Go
- Stelle
- 19
- Fork
- 3
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di LinuxSuRen/gogit
-
Docs: replace the real-looking access token in README examples and fix build status help textsForse già presa @linuxsuren-fs l’ha presa 7 giorni fa. Apertadocumentation good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
LinuxSuRen/gogit#90 ·
-
Bug: --token file://… content is not trimmed, trailing newline breaks authenticationForse già presa @linuxsuren-fs l’ha presa 7 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
LinuxSuRen/gogit#87 ·
-
Bug: gogit checkout robustness: remotes[0] panic, wrong error message, empty version output, non-idempotent 0444 writesForse già presa @linuxsuren-fs l’ha presa 7 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LinuxSuRen/gogit#86 ·
-
Bug: DingTalk notification builds JSON by string concatenation, echoes the token, leaks resp.Body and swallows errorsForse già presa @linuxsuren-fs l’ha presa 7 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
LinuxSuRen/gogit#84 ·
-
Security: git access token is printed into pod logs by the Argo Workflows executorForse già presa @linuxsuren-fs l’ha presa 7 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LinuxSuRen/gogit#83 ·
Tutte le issue di LinuxSuRen/gogit
Issue simili
-
Sign-off cards drift between formats; write down one card formatForse già presa @keyxmakerx l’ha presa oggi. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
keyxmakerx/Chronicle#2795 ·
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
refactor review: high
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
1lck/Lithe-IDEA#2376 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
OneBusAway/vehicle-positions#614 ·
I maintainer di solito rispondono entro 1 giorno