Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
belug23 opened this issue Feb 9, 2024 · 0 comments
Open

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

belug23 opened this issue Feb 9, 2024 · 0 comments

Comments

@belug23
Copy link

belug23 commented Feb 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant