Bug: gogit checkout fails on repositories whose default branch is not master
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 85/100
Línea de trabajo
Empieza en cmd/checkout.go: el valor predeterminado de la flag --branch se establece cerca de la línea 46 y el git.CloneOptions con ReferenceName se construye alrededor de la línea 82, donde c.Flags().Changed("branch") ya se usa más abajo. Condiciona ReferenceName a esa misma comprobación para que no se envíe ninguna ref de rama cuando la flag se dejó tal cual, manteniendo sin cambios la ruta de rama explícita. Hecho significa que gogit checkout contra un repo con una rama predeterminada main clona correctamente, y las pruebas de checkout existentes siguen pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 19
- Forks
- 3
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de LinuxSuRen/gogit
-
Docs: replace the real-looking access token in README examples and fix build status help textsPosiblemente ocupada @linuxsuren-fs la tomó hace 7 días. Abiertodocumentation good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
LinuxSuRen/gogit#90 ·
-
Bug: --token file://… content is not trimmed, trailing newline breaks authenticationPosiblemente ocupada @linuxsuren-fs la tomó hace 7 días. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
LinuxSuRen/gogit#87 ·
-
Bug: gogit checkout robustness: remotes[0] panic, wrong error message, empty version output, non-idempotent 0444 writesPosiblemente ocupada @linuxsuren-fs la tomó hace 7 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
LinuxSuRen/gogit#86 ·
-
Bug: DingTalk notification builds JSON by string concatenation, echoes the token, leaks resp.Body and swallows errorsPosiblemente ocupada @linuxsuren-fs la tomó hace 7 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
LinuxSuRen/gogit#84 ·
-
Security: git access token is printed into pod logs by the Argo Workflows executorPosiblemente ocupada @linuxsuren-fs la tomó hace 7 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
LinuxSuRen/gogit#83 ·
Todos los issues de LinuxSuRen/gogit
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
VictoriaMetrics/VictoriaLogs#1965 ·
Los mantenedores suelen responder en 1 día
-
Sign-off cards drift between formats; write down one card formatPosiblemente ocupada @keyxmakerx la tomó hoy. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
keyxmakerx/Chronicle#2795 ·
Los mantenedores suelen responder en 1 día
-
bug ElasticSearch
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
aliyun/terraform-provider-alicloud#11614 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 2 días
-
[Bug]: Quick chat and quick terminal text renders blurry in WebKit (Orion), sharp in ChromiumAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día