summaryrefslogtreecommitdiff
path: root/coverage/html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-12 19:06:14 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-12 19:06:14 -0500
commitb471e55a92718fa4711c040edc88308d5101fc86 (patch)
treeb85b5eef38b5a9034fa67bf6efbc54ad7aaee279 /coverage/html.py
parentbf42d44403351cd35d67af5bc1bb9b284ad1a08b (diff)
downloadpython-coveragepy-git-b471e55a92718fa4711c040edc88308d5101fc86.tar.gz
fix: don't overwrite a .gitignore in the html output directory. #1244nedbat/1244-again
Diffstat (limited to 'coverage/html.py')
-rw-r--r--coverage/html.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 52689050..d018d0f0 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -226,8 +226,10 @@ class HtmlReporter:
# .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")
+ gitigore_path = os.path.join(self.directory, ".gitignore")
+ if not os.path.exists(gitigore_path):
+ with open(gitigore_path, "w") as fgi:
+ fgi.write("# Created by coverage.py\n*\n")
# The user may have extra CSS they want copied.
if self.extra_css: