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

Improve error reporting when "git" is not found #303

Open
barrywhart opened this issue Nov 30, 2022 · 0 comments
Open

Improve error reporting when "git" is not found #303

barrywhart opened this issue Nov 30, 2022 · 0 comments

Comments

@barrywhart
Copy link
Contributor

If git is not installed or isn't in the user's PATH, diff-quality fails with an error that non-technical (SQLFluff, other?) users find confusing:

$ diff-quality --violations sqlfluff
Traceback (most recent call last):
  File "/app/.venv/bin/diff-quality", line 8, in <module>
    sys.exit(main())
  File "/app/.venv/lib/python3.9/site-packages/diff_cover/diff_quality_tool.py", line 300, in main
    GitPathTool.set_cwd(directory)
  File "/app/.venv/lib/python3.9/site-packages/diff_cover/git_path.py", line 33, in set_cwd
    cls._root = cls._git_root()
  File "/app/.venv/lib/python3.9/site-packages/diff_cover/git_path.py", line 65, in _git_root
    git_root = execute(command)[0]
  File "/app/.venv/lib/python3.9/site-packages/diff_cover/command_runner.py", line 27, in execute
    process = subprocess.Popen(command, stdout=stdout_pipe, stderr=stdout_pipe)
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

Perhaps it could catch this error and print a message something like:

<<command name>> requires git to be installed and in your PATH, but it was not found.

It could also link to this page, which has instructions for installing git on various OSes.

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

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