Git submodule fials if branch not present
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 1.7k
- Forks
- 408
- Merge medio
- 2 d 57 min
- PR fusionados (30 d)
- 7
Descripción
In case if I want to check if branch was provided to submodule and it is not provided I got error
if sm.branch:
name = f"{sm.branch}/{sm.name}"
else:
name = f"{sm.name}"
File "/app/venv/lib/python3.11/site-packages/pygit2/submodules.py", line 148, in branch return ffi.string(branch).decode('utf-8') ^^^^^^^^^^^^^^^^^^ RuntimeError: cannot use string() on <cdata 'char *' NULL>
It looks like there is missing check if branch is actually set
class Submodule:
...
@property
def branch(self):
"""Branch that is to be tracked by the submodule."""
branch = C.git_submodule_branch(self._subm)
return ffi.string(branch).decode('utf-8')
I think it should be like this
@property
def branch(self):
"""Branch that is to be tracked by the submodule."""
branch = C.git_submodule_branch(self._subm)
if branch:
return ffi.string(branch).decode('utf-8')
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.
Línea de trabajo
Comienza en pygit2/submodules.py, en la propiedad Submodule.branch, e inspecciona cómo C.git_submodule_branch devuelve un branch no establecido. Verifica el comportamiento para un submódulo sin un branch configurado y confirma que acceder a la propiedad ya no provoca el RuntimeError de NULL cdata informado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- git, python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 58/100