Skip to content

Commit

Permalink
Merge pull request #465 from GitGuardian/plalanne/-/improve-git-error…
Browse files Browse the repository at this point in the history
…-management

Improve error management to better catch some git errors
  • Loading branch information
agateau-gg authored Jan 31, 2023
2 parents bbf398e + bdfc982 commit 9af97cf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ggshield/core/git_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ def git(
cwd=cwd,
)
return result.stdout.decode("utf-8", errors="ignore").rstrip()
except subprocess.CalledProcessError as e:
if "detected dubious ownership in repository" in e.stderr.decode(
"utf-8", errors="ignore"
):
raise UnexpectedError(
"Git command failed because of a dubious ownership in repository.\n"
"If you still want to run ggshield, make sure you mark "
"the current repository as safe for git with:\n"
" git config --global --add safe.repository <YOUR_REPO>"
)
raise e
except subprocess.TimeoutExpired:
raise click.Abort('Command "{}" timed out'.format(" ".join(command)))

Expand Down

0 comments on commit 9af97cf

Please sign in to comment.