Git error messages are hidden when getting error on a branch

Abierto
#140 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
git, typescript
Área
cli

Línea de trabajo

Start at src/utils/ValidationsHandler.ts around line 174, where the branch commit lookup currently hides Git errors. Reproduce the branch lookup failure with a Docker-mounted repository and verify that the CLI preserves and displays Git's diagnostic output alongside the existing error. Done means users can see the underlying Git failure instead of only the generic message.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

We had a problem recently where caprover-cli was showing an error message, but it didn't make any senses:

Cannot find hash of last commit on branch "master".

After a few researches I've found the code that make the error and ran it.

# git rev-parse master
fatal: detected dubious ownership in repository at '<folder>'
To add an exception for this directory, call:

	git config --global --add safe.directory <folder>

I've found a similar issue #122 their problem was solved by, not using sudo, but our problem is because we're using docker to run caprover-cli with a volume that is linked to our project folder.

The real issue here is that the code https://github.com/caprover/caprover-cli/blob/c7cdb49850a932c275893ae4289ed16f75c47a1c/src/utils/ValidationsHandler.ts#L174 is obscuring the git error message.

I have a suggestion to display the git error, instead of sending it to /dev/null we could send the error message to a temporary file and print the content when we encounter the error. Being able to have the proper error would have saved us a lot of time.

The program could print something like:

Cannot find hash of last commit on branch "master". Git returned the following errors:
    fatal: detected dubious ownership in repository at '<folder>'
    To add an exception for this directory, call:

    	    git config --global --add safe.directory <folder>

I would be willing to work on the pull request to add this behaviour.

P.S. for people that have the same problem and are using the caprover/caprover-cli's docker with an upgraded version of git, we added RUN git config --global --add safe.directory <the path of our volume folder> to our Dockerfile to fix the error. We allowed this because we control the docker and it's running locally on our dev's machines, meaning that it's not causing security issues with our workflow.

Lenguaje dominante
TypeScript
Estrellas
78
Forks
42
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de caprover/caprover-cli

Todos los issues de caprover/caprover-cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.