From b471e55a92718fa4711c040edc88308d5101fc86 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 12 Nov 2021 19:06:14 -0500 Subject: fix: don't overwrite a .gitignore in the html output directory. #1244 --- coverage/html.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'coverage/html.py') 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: -- cgit v1.2.1