File tree 3 files changed +14
-2
lines changed 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ Unreleased
25
25
- Fix: A colon in a decorator expression would cause an exclusion to end too
26
26
early, preventing the exclusion of the decorated function. This is now fixed.
27
27
28
+ - Fix: The HTML report now will not overwrite a .gitignore file that already
29
+ exists in the HTML output directory (follow-on for `issue 1244 `_).
30
+
28
31
29
32
.. _changes_612 :
30
33
Original file line number Diff line number Diff line change @@ -226,8 +226,10 @@ def make_local_static_report_files(self):
226
226
227
227
# .gitignore can't be copied from the source tree because it would
228
228
# prevent the static files from being checked in.
229
- with open (os .path .join (self .directory , ".gitignore" ), "w" ) as fgi :
230
- fgi .write ("# Created by coverage.py\n *\n " )
229
+ gitigore_path = os .path .join (self .directory , ".gitignore" )
230
+ if not os .path .exists (gitigore_path ):
231
+ with open (gitigore_path , "w" ) as fgi :
232
+ fgi .write ("# Created by coverage.py\n *\n " )
231
233
232
234
# The user may have extra CSS they want copied.
233
235
if self .extra_css :
Original file line number Diff line number Diff line change @@ -284,6 +284,13 @@ def test_status_format_change(self):
284
284
assert "htmlcov/helper2_py.html" in self .files_written
285
285
assert "htmlcov/main_file_py.html" in self .files_written
286
286
287
+ def test_dont_overwrite_gitignore (self ):
288
+ self .create_initial_files ()
289
+ self .make_file ("htmlcov/.gitignore" , "# ignore nothing" )
290
+ self .run_coverage ()
291
+ with open ("htmlcov/.gitignore" ) as fgi :
292
+ assert fgi .read () == "# ignore nothing"
293
+
287
294
288
295
class HtmlTitleTest (HtmlTestHelpers , CoverageTest ):
289
296
"""Tests of the HTML title support."""
You can’t perform that action at this time.
0 commit comments