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

Option to skip diff-cover when not in a git repository #267

Open
warsaw opened this issue Jan 11, 2022 · 1 comment
Open

Option to skip diff-cover when not in a git repository #267

warsaw opened this issue Jan 11, 2022 · 1 comment

Comments

@warsaw
Copy link

warsaw commented Jan 11, 2022

I have the following commands in my tox.ini [testenv] section:

commands =
    pdm config --local use_venv True
    pdm install -G testing
    pytest {posargs}
    # The following is only useful in a git repository.
    diff-cover coverage.xml

I'd like for tox to be runnable from an unpacked sdist, but that won't be in a git repository, so it fails like so:

py310 run-test: commands[3] | -diff-cover coverage.xml
Traceback (most recent call last):
  File "/private/tmp/testing/atpublic-3.0/.tox/py310/bin/diff-cover", line 8, in <module>
    sys.exit(main())
  File "/private/tmp/testing/atpublic-3.0/.tox/py310/lib/python3.10/site-packages/diff_cover/diff_cover_tool.py", line 258, in main
    GitPathTool.set_cwd(directory)
  File "/private/tmp/testing/atpublic-3.0/.tox/py310/lib/python3.10/site-packages/diff_cover/git_path.py", line 33, in set_cwd
    cls._root = cls._git_root()
  File "/private/tmp/testing/atpublic-3.0/.tox/py310/lib/python3.10/site-packages/diff_cover/git_path.py", line 65, in _git_root
    git_root = execute(command)[0]
  File "/private/tmp/testing/atpublic-3.0/.tox/py310/lib/python3.10/site-packages/diff_cover/command_runner.py", line 45, in execute
    raise CommandError(stderr)
diff_cover.command_runner.CommandError: fatal: not a git repository (or any of the parent directories): .git

I can prefix the diff-cover command with - in my tox.ini so the error won't fail the test, but I'd rather provide an option to diff-cover that essentially says "skip me without an error if I'm not in a git repository".

@ArleneCheung
Copy link

Hello,I want to ask you some questions.Do you now have some progress about this problem? I also want to use diff cover without git.I want to use diff cover in SVN!!!

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

2 participants