Skip to content

Git error messages are hidden when getting error on a branch #140

Open
@belug23

Description

@belug23

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

: execSync(`git rev-parse ${value} 2>/dev/null`)
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions