mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Don’t touch VCS file if it isn’t modified // Issue #848
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user