Skip to content

Commit

Permalink
fix(git): ignore invalid utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Nov 2, 2021
1 parent 4bac36d commit 31849a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ggshield/git_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def shell(command: List[str], timeout: int = COMMAND_TIMEOUT) -> str:
stderr=subprocess.PIPE,
timeout=timeout,
)
return result.stdout.decode("utf-8").rstrip()
return result.stdout.decode("utf-8", errors="ignore").rstrip()
except subprocess.CalledProcessError:
pass
except subprocess.TimeoutExpired:
raise click.Abort('Command "{}" timed out'.format(" ".join(command)))
except Exception as exc:
raise click.ClickException(f"Unhandled exception: {str(exc)}")
raise click.ClickException(
f"Unhandled exception: {' '.join(command)}\n\t{str(exc)}"
)

return ""

Expand Down

0 comments on commit 31849a8

Please sign in to comment.