diff-cover 9.0.0__tar.gz → 9.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diff_cover-9.0.0 → diff_cover-9.1.0}/PKG-INFO +28 -1
- {diff_cover-9.0.0 → diff_cover-9.1.0}/README.rst +27 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/diff_cover_tool.py +16 -6
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/git_diff.py +35 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/pyproject.toml +4 -4
- diff_cover-9.1.0/tests/test_git_diff_file.py +72 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/LICENSE +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/__init__.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/command_runner.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/config_parser.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/diff_quality_tool.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/diff_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/git_path.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/hook.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/hookspecs.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/report_generator.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/snippets.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/console_coverage_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/console_quality_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/external_style.css +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/html_coverage_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/html_quality_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/markdown_coverage_report.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/markdown_quality_report.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/snippet_content.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/snippet_content.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/snippet_content.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/templates/snippet_style.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/util.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/violationsreporters/__init__.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/violationsreporters/base.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/violationsreporters/java_violations_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/violationsreporters/violations_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/__init__.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/add_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/add_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/changed_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/changed_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/coverage.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/coverage1.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/coverage2.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/delete_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/delete_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/dotnet_coverage.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/dotnet_coverage_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/empty.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/empty_pycodestyle_violations.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/external_css_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/external_style.css +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_add.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_changed.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_code_dupe.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_delete.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_dotnet.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_external_css.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_lua.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_moved.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_mult.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_subdir.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_unicode.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_violations.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/git_diff_violations_two_files.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/hello.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/hi.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/html_report_empty.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/html_report_one_snippet.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/html_report_two_snippets.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/lcov.info +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/lua_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/luacoverage.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/markdown_report_one_snippet.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/markdown_report_two_snippets.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/moved_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/moved_coverage.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/moved_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/mult_inputs_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/mult_inputs_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pycodestyle_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pycodestyle_violations_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pycodestyle_violations_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pycodestyle_violations_report_external_css.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pyflakes_two_files.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pyflakes_violations_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pyflakes_violations_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_dupe.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_dupe_violations_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_violations_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_violations_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylint_violations_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pylintrc +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/show_uncovered_lines_console.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet.css +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_8859.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_arabic_output.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_default.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_invalid_violations.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_list.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_list.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_list2.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_list3.md +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_no_filename_ext.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_src.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_src2.cpp +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_src3.cpp +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_unicode.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_unicode.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/snippet_unicode_html_output.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/subdir_coverage_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/subdir_coverage_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/test_src.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/unicode_console_report.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/unicode_coverage.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/unicode_html_report.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/unicode_test_src.txt +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/violations_test_file.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/helpers.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/snippet_list_unicode.html +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_clover_violations_reporter/test.xml +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_clover_violations_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_config_parser.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_diff_cover_main.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_diff_cover_tool.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_diff_quality_main.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_diff_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_git_diff.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_git_path.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_integration.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_java_violations_reporter.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_report_generator.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_snippets.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_util.py +0 -0
- {diff_cover-9.0.0 → diff_cover-9.1.0}/tests/test_violations_reporter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: diff_cover
|
|
3
|
-
Version: 9.
|
|
3
|
+
Version: 9.1.0
|
|
4
4
|
Summary: Run coverage and linting reports on diffs
|
|
5
5
|
Home-page: https://github.com/Bachmann1234/diff-cover
|
|
6
6
|
License: Apache-2.0
|
|
@@ -223,6 +223,33 @@ By default, ``diff-cover`` compares the current branch to ``origin/main``. To s
|
|
|
223
223
|
|
|
224
224
|
diff-cover coverage.xml --compare-branch=origin/release
|
|
225
225
|
|
|
226
|
+
Diff File
|
|
227
|
+
--------------
|
|
228
|
+
|
|
229
|
+
You may provide a file containing the output of ``git diff`` to ``diff-cover`` instead of using a branch name.
|
|
230
|
+
|
|
231
|
+
For example, Say you have 2 branches ``main`` and ``feature``. Lets say after creating and checking out the feature branch,
|
|
232
|
+
you make commits ``A``, ``B``, and ``C`` in that order.
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
If you want to see all changes between the ``feature`` and ``main`` branch, you can generate a diff file like this:
|
|
236
|
+
|
|
237
|
+
.. code:: bash
|
|
238
|
+
|
|
239
|
+
git diff main..feature > diff.txt
|
|
240
|
+
|
|
241
|
+
If you want to see the changes between the ``feature`` branch and the commit ``A``, you can generate a diff file using the following command:
|
|
242
|
+
|
|
243
|
+
.. code:: bash
|
|
244
|
+
|
|
245
|
+
git diff A..feature > diff.txt
|
|
246
|
+
|
|
247
|
+
You can then run ``diff-cover`` with the diff file as an argument:
|
|
248
|
+
|
|
249
|
+
.. code:: bash
|
|
250
|
+
|
|
251
|
+
diff-cover coverage.xml --diff-file=diff.txt
|
|
252
|
+
|
|
226
253
|
Fail Under
|
|
227
254
|
----------
|
|
228
255
|
|
|
@@ -190,6 +190,33 @@ By default, ``diff-cover`` compares the current branch to ``origin/main``. To s
|
|
|
190
190
|
|
|
191
191
|
diff-cover coverage.xml --compare-branch=origin/release
|
|
192
192
|
|
|
193
|
+
Diff File
|
|
194
|
+
--------------
|
|
195
|
+
|
|
196
|
+
You may provide a file containing the output of ``git diff`` to ``diff-cover`` instead of using a branch name.
|
|
197
|
+
|
|
198
|
+
For example, Say you have 2 branches ``main`` and ``feature``. Lets say after creating and checking out the feature branch,
|
|
199
|
+
you make commits ``A``, ``B``, and ``C`` in that order.
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
If you want to see all changes between the ``feature`` and ``main`` branch, you can generate a diff file like this:
|
|
203
|
+
|
|
204
|
+
.. code:: bash
|
|
205
|
+
|
|
206
|
+
git diff main..feature > diff.txt
|
|
207
|
+
|
|
208
|
+
If you want to see the changes between the ``feature`` branch and the commit ``A``, you can generate a diff file using the following command:
|
|
209
|
+
|
|
210
|
+
.. code:: bash
|
|
211
|
+
|
|
212
|
+
git diff A..feature > diff.txt
|
|
213
|
+
|
|
214
|
+
You can then run ``diff-cover`` with the diff file as an argument:
|
|
215
|
+
|
|
216
|
+
.. code:: bash
|
|
217
|
+
|
|
218
|
+
diff-cover coverage.xml --diff-file=diff.txt
|
|
219
|
+
|
|
193
220
|
Fail Under
|
|
194
221
|
----------
|
|
195
222
|
|
|
@@ -8,7 +8,7 @@ import xml.etree.ElementTree as etree
|
|
|
8
8
|
from diff_cover import DESCRIPTION, VERSION
|
|
9
9
|
from diff_cover.config_parser import Tool, get_config
|
|
10
10
|
from diff_cover.diff_reporter import GitDiffReporter
|
|
11
|
-
from diff_cover.git_diff import GitDiffTool
|
|
11
|
+
from diff_cover.git_diff import GitDiffFileTool, GitDiffTool
|
|
12
12
|
from diff_cover.git_path import GitPathTool
|
|
13
13
|
from diff_cover.report_generator import (
|
|
14
14
|
HtmlReportGenerator,
|
|
@@ -43,6 +43,7 @@ QUIET_HELP = "Only print errors and failures"
|
|
|
43
43
|
SHOW_UNCOVERED = "Show uncovered lines on the console"
|
|
44
44
|
INCLUDE_UNTRACKED_HELP = "Include untracked files"
|
|
45
45
|
CONFIG_FILE_HELP = "The configuration file to use"
|
|
46
|
+
DIFF_FILE_HELP = "The diff file to use"
|
|
46
47
|
|
|
47
48
|
LOGGER = logging.getLogger(__name__)
|
|
48
49
|
|
|
@@ -169,6 +170,8 @@ def parse_coverage_args(argv):
|
|
|
169
170
|
"-c", "--config-file", help=CONFIG_FILE_HELP, metavar="CONFIG_FILE"
|
|
170
171
|
)
|
|
171
172
|
|
|
173
|
+
parser.add_argument("--diff-file", type=str, default=None, help=DIFF_FILE_HELP)
|
|
174
|
+
|
|
172
175
|
defaults = {
|
|
173
176
|
"show_uncovered": False,
|
|
174
177
|
"compare_branch": "origin/main",
|
|
@@ -188,6 +191,7 @@ def parse_coverage_args(argv):
|
|
|
188
191
|
def generate_coverage_report(
|
|
189
192
|
coverage_files,
|
|
190
193
|
compare_branch,
|
|
194
|
+
diff_tool,
|
|
191
195
|
html_report=None,
|
|
192
196
|
css_file=None,
|
|
193
197
|
json_report=None,
|
|
@@ -198,8 +202,6 @@ def generate_coverage_report(
|
|
|
198
202
|
exclude=None,
|
|
199
203
|
include=None,
|
|
200
204
|
src_roots=None,
|
|
201
|
-
diff_range_notation=None,
|
|
202
|
-
ignore_whitespace=False,
|
|
203
205
|
quiet=False,
|
|
204
206
|
show_uncovered=False,
|
|
205
207
|
):
|
|
@@ -208,7 +210,7 @@ def generate_coverage_report(
|
|
|
208
210
|
"""
|
|
209
211
|
diff = GitDiffReporter(
|
|
210
212
|
compare_branch,
|
|
211
|
-
git_diff=
|
|
213
|
+
git_diff=diff_tool,
|
|
212
214
|
ignore_staged=ignore_staged,
|
|
213
215
|
ignore_unstaged=ignore_unstaged,
|
|
214
216
|
include_untracked=include_untracked,
|
|
@@ -281,9 +283,19 @@ def main(argv=None, directory=None):
|
|
|
281
283
|
|
|
282
284
|
GitPathTool.set_cwd(directory)
|
|
283
285
|
fail_under = arg_dict.get("fail_under")
|
|
286
|
+
diff_tool = None
|
|
287
|
+
|
|
288
|
+
if not arg_dict["diff_file"]:
|
|
289
|
+
diff_tool = GitDiffTool(
|
|
290
|
+
arg_dict["diff_range_notation"], arg_dict["ignore_whitespace"]
|
|
291
|
+
)
|
|
292
|
+
else:
|
|
293
|
+
diff_tool = GitDiffFileTool(arg_dict["diff_file"])
|
|
294
|
+
|
|
284
295
|
percent_covered = generate_coverage_report(
|
|
285
296
|
arg_dict["coverage_file"],
|
|
286
297
|
arg_dict["compare_branch"],
|
|
298
|
+
diff_tool,
|
|
287
299
|
html_report=arg_dict["html_report"],
|
|
288
300
|
json_report=arg_dict["json_report"],
|
|
289
301
|
markdown_report=arg_dict["markdown_report"],
|
|
@@ -294,8 +306,6 @@ def main(argv=None, directory=None):
|
|
|
294
306
|
exclude=arg_dict["exclude"],
|
|
295
307
|
include=arg_dict["include"],
|
|
296
308
|
src_roots=arg_dict["src_roots"],
|
|
297
|
-
diff_range_notation=arg_dict["diff_range_notation"],
|
|
298
|
-
ignore_whitespace=arg_dict["ignore_whitespace"],
|
|
299
309
|
quiet=quiet,
|
|
300
310
|
show_uncovered=arg_dict["show_uncovered"],
|
|
301
311
|
)
|
|
@@ -110,3 +110,38 @@ class GitDiffTool:
|
|
|
110
110
|
if not output:
|
|
111
111
|
return []
|
|
112
112
|
return [line for line in output.splitlines() if line]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class GitDiffFileTool(GitDiffTool):
|
|
116
|
+
|
|
117
|
+
def __init__(self, diff_file_path):
|
|
118
|
+
|
|
119
|
+
self.diff_file_path = diff_file_path
|
|
120
|
+
super().__init__("...", False)
|
|
121
|
+
|
|
122
|
+
def diff_committed(self, compare_branch="origin/main"):
|
|
123
|
+
"""
|
|
124
|
+
Returns the contents of a diff file.
|
|
125
|
+
|
|
126
|
+
Raises a `GitDiffError` if the file cannot be read.
|
|
127
|
+
"""
|
|
128
|
+
try:
|
|
129
|
+
with open(self.diff_file_path, "r") as file:
|
|
130
|
+
return file.read()
|
|
131
|
+
except IOError as e:
|
|
132
|
+
raise ValueError(
|
|
133
|
+
dedent(
|
|
134
|
+
f"""
|
|
135
|
+
Could not read the diff file. Make sure '{self.diff_file_path}' exists?
|
|
136
|
+
"""
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def diff_unstaged(self):
|
|
141
|
+
return ""
|
|
142
|
+
|
|
143
|
+
def diff_staged(self):
|
|
144
|
+
return ""
|
|
145
|
+
|
|
146
|
+
def untracked(self):
|
|
147
|
+
return ""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "diff_cover"
|
|
3
|
-
version = "9.
|
|
3
|
+
version = "9.1.0"
|
|
4
4
|
description = "Run coverage and linting reports on diffs"
|
|
5
5
|
authors = ["See Contributors"]
|
|
6
6
|
homepage = "https://github.com/Bachmann1234/diff-cover"
|
|
@@ -55,10 +55,10 @@ pytest-mock = "^3.14.0"
|
|
|
55
55
|
pycodestyle = ">=2.9.1"
|
|
56
56
|
flake8 = "^5.0.4"
|
|
57
57
|
pyflakes = "^2.5.0"
|
|
58
|
-
pylint = "^3.
|
|
59
|
-
pylint-pytest = "^1.1.
|
|
58
|
+
pylint = "^3.2.2"
|
|
59
|
+
pylint-pytest = "^1.1.8"
|
|
60
60
|
pydocstyle = "^6.1.1"
|
|
61
|
-
black = "^24.
|
|
61
|
+
black = "^24.4.2"
|
|
62
62
|
isort = "^5.13.2"
|
|
63
63
|
doc8 = "1.1.1"
|
|
64
64
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# pylint: disable=missing-function-docstring
|
|
2
|
+
|
|
3
|
+
"""Test for diff_cover.git_diff.GitDiffFileTool"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from diff_cover.git_diff import GitDiffFileTool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def mock_file(mocker):
|
|
12
|
+
def _inner(file_content):
|
|
13
|
+
mock_open = mocker.mock_open(read_data=file_content)
|
|
14
|
+
mocker.patch("builtins.open", mock_open)
|
|
15
|
+
|
|
16
|
+
return _inner
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def diff_tool():
|
|
21
|
+
def _inner(file):
|
|
22
|
+
return GitDiffFileTool(file)
|
|
23
|
+
|
|
24
|
+
return _inner
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_diff_file_not_found(mocker, diff_tool):
|
|
28
|
+
mocker.patch("builtins.open", side_effect=IOError)
|
|
29
|
+
|
|
30
|
+
_diff_tool = diff_tool("non_existent_diff_file.txt")
|
|
31
|
+
|
|
32
|
+
with pytest.raises(ValueError) as excinfo:
|
|
33
|
+
_diff_tool.diff_committed()
|
|
34
|
+
|
|
35
|
+
assert (
|
|
36
|
+
f"Could not read the diff file. Make sure '{_diff_tool.diff_file_path}' exists?"
|
|
37
|
+
in str(excinfo.value)
|
|
38
|
+
)
|
|
39
|
+
assert _diff_tool.diff_file_path == "non_existent_diff_file.txt"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_large_diff_file(mock_file, diff_tool):
|
|
43
|
+
large_diff = "diff --git a/file1 b/file2\n" * 1000000
|
|
44
|
+
|
|
45
|
+
mock_file(large_diff)
|
|
46
|
+
|
|
47
|
+
_diff_tool = diff_tool("large_diff_file.txt")
|
|
48
|
+
|
|
49
|
+
assert _diff_tool.diff_committed() == large_diff
|
|
50
|
+
assert _diff_tool.diff_file_path == "large_diff_file.txt"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_diff_committed(mock_file, diff_tool):
|
|
54
|
+
diff = "diff --git a/file1 b/file2\n"
|
|
55
|
+
|
|
56
|
+
mock_file(diff)
|
|
57
|
+
|
|
58
|
+
_diff_tool = diff_tool("diff_file.txt")
|
|
59
|
+
|
|
60
|
+
assert _diff_tool.diff_committed() == diff
|
|
61
|
+
assert _diff_tool.diff_file_path == "diff_file.txt"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_empty_diff_file(mock_file, diff_tool):
|
|
65
|
+
empty_diff = ""
|
|
66
|
+
|
|
67
|
+
mock_file(empty_diff)
|
|
68
|
+
|
|
69
|
+
_diff_tool = diff_tool("empty_diff.txt")
|
|
70
|
+
|
|
71
|
+
assert _diff_tool.diff_committed() == empty_diff
|
|
72
|
+
assert _diff_tool.diff_file_path == "empty_diff.txt"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diff_cover-9.0.0 → diff_cover-9.1.0}/diff_cover/violationsreporters/java_violations_reporter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diff_cover-9.0.0 → diff_cover-9.1.0}/tests/fixtures/pycodestyle_violations_report_external_css.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|