diff options
-rw-r--r-- | .github/workflows/coverage.yml | 1 | ||||
-rw-r--r-- | CHANGES.rst | 5 | ||||
-rw-r--r-- | coverage/html.py | 5 | ||||
-rw-r--r-- | howto.txt | 2 | ||||
-rw-r--r-- | tests/test_html.py | 1 |
5 files changed, 14 insertions, 0 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0b0f41ea..cbfd44ec 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -116,6 +116,7 @@ jobs: run: | set -xe python -m igor combine_html + rm htmlcov/.gitignore python -m coverage json echo "::set-output name=total::$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")" diff --git a/CHANGES.rst b/CHANGES.rst index 3d3bcb1b..5298c51e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -37,6 +37,10 @@ Unreleased a ``-q/--quiet`` option to suppress the messages they write to stdout about what they are doing (`issue 1254`_). +- Feature: The ``html`` command writes a ``.gitignore`` file into the HTML + output directory, to prevent the report from being committed to git. If you + want to commit it, you will need to delete that file. Closes `issue 1244`_. + - Feature: Added support for PyPy 3.8. - Fix: more generated code is now excluded from measurement. Code such as @@ -58,6 +62,7 @@ Unreleased .. _issue 553: https://github.com/nedbat/coveragepy/issues/553 .. _issue 840: https://github.com/nedbat/coveragepy/issues/840 .. _issue 1160: https://github.com/nedbat/coveragepy/issues/1160 +.. _issue 1244: https://github.com/nedbat/coveragepy/issues/1244 .. _issue 1254: https://github.com/nedbat/coveragepy/issues/1254 .. _attrs: https://www.attrs.org/ diff --git a/coverage/html.py b/coverage/html.py index 6246a9b9..52689050 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -224,6 +224,11 @@ class HtmlReporter: for static in self.STATIC_FILES: shutil.copyfile(data_filename(static), os.path.join(self.directory, static)) + # .gitignore can't be copied from the source tree because it would + # prevent the static files from being checked in. + with open(os.path.join(self.directory, ".gitignore"), "w") as fgi: + fgi.write("# Created by coverage.py\n*\n") + # The user may have extra CSS they want copied. if self.extra_css: shutil.copyfile(self.config.extra_css, os.path.join(self.directory, self.extra_css)) @@ -30,9 +30,11 @@ - IF PRE-RELEASE: $ rm -f ~/coverage/trunk/doc/sample_html_beta/*.* $ cp -r htmlcov/ ~/coverage/trunk/doc/sample_html_beta/ + $ rm ~/coverage/trunk/doc/sample_html_beta/.gitignore - IF NOT PRE-RELEASE: $ rm -f ~/coverage/trunk/doc/sample_html/*.* $ cp -r htmlcov/ ~/coverage/trunk/doc/sample_html/ + $ rm ~/coverage/trunk/doc/sample_html/.gitignore $ cd ~/coverage/trunk - IF NOT PRE-RELEASE: check in the new sample html diff --git a/tests/test_html.py b/tests/test_html.py index 849be567..0e697545 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -144,6 +144,7 @@ class HtmlDeltaTest(HtmlTestHelpers, CoverageTest): self.assert_exists("htmlcov/helper2_py.html") self.assert_exists("htmlcov/style.css") self.assert_exists("htmlcov/coverage_html.js") + self.assert_exists("htmlcov/.gitignore") def test_html_created(self): # Test basic HTML generation: files should be created. |