Don’t touch VCS file if it isn’t modified // Issue #848

This commit is contained in:
Ivan Kravets
2016-12-07 00:58:22 +02:00
parent ac01a37f5f
commit b26442d1fe
2 changed files with 8 additions and 0 deletions

View File

@ -273,6 +273,7 @@ def init_cvs_ignore(project_dir):
ignore_path = join(project_dir, ".gitignore")
default = [".pioenvs\n", ".piolibdeps\n"]
current = []
modified = False
if isfile(ignore_path):
with open(ignore_path) as fp:
current = fp.readlines()
@ -280,7 +281,10 @@ def init_cvs_ignore(project_dir):
current[-1] += "\n"
for d in default:
if d not in current:
modified = True
current.append(d)
if not modified:
return
with open(ignore_path, "w") as fp:
fp.writelines(current)

View File

@ -127,12 +127,16 @@ class ProjectGenerator(object):
# merge .gitignore
if file_name == ".gitignore" and isfile(dst_path):
modified = False
default = [l.strip() for l in contents.split("\n")]
with open(dst_path) as fp:
current = [l.strip() for l in fp.readlines()]
for d in default:
if d and d not in current:
modified = True
current.append(d)
if not modified:
return
contents = "\n".join(current) + "\n"
with open(dst_path, "w") as f: