mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07: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")
|
ignore_path = join(project_dir, ".gitignore")
|
||||||
default = [".pioenvs\n", ".piolibdeps\n"]
|
default = [".pioenvs\n", ".piolibdeps\n"]
|
||||||
current = []
|
current = []
|
||||||
|
modified = False
|
||||||
if isfile(ignore_path):
|
if isfile(ignore_path):
|
||||||
with open(ignore_path) as fp:
|
with open(ignore_path) as fp:
|
||||||
current = fp.readlines()
|
current = fp.readlines()
|
||||||
@ -280,7 +281,10 @@ def init_cvs_ignore(project_dir):
|
|||||||
current[-1] += "\n"
|
current[-1] += "\n"
|
||||||
for d in default:
|
for d in default:
|
||||||
if d not in current:
|
if d not in current:
|
||||||
|
modified = True
|
||||||
current.append(d)
|
current.append(d)
|
||||||
|
if not modified:
|
||||||
|
return
|
||||||
with open(ignore_path, "w") as fp:
|
with open(ignore_path, "w") as fp:
|
||||||
fp.writelines(current)
|
fp.writelines(current)
|
||||||
|
|
||||||
|
@ -127,12 +127,16 @@ class ProjectGenerator(object):
|
|||||||
|
|
||||||
# merge .gitignore
|
# merge .gitignore
|
||||||
if file_name == ".gitignore" and isfile(dst_path):
|
if file_name == ".gitignore" and isfile(dst_path):
|
||||||
|
modified = False
|
||||||
default = [l.strip() for l in contents.split("\n")]
|
default = [l.strip() for l in contents.split("\n")]
|
||||||
with open(dst_path) as fp:
|
with open(dst_path) as fp:
|
||||||
current = [l.strip() for l in fp.readlines()]
|
current = [l.strip() for l in fp.readlines()]
|
||||||
for d in default:
|
for d in default:
|
||||||
if d and d not in current:
|
if d and d not in current:
|
||||||
|
modified = True
|
||||||
current.append(d)
|
current.append(d)
|
||||||
|
if not modified:
|
||||||
|
return
|
||||||
contents = "\n".join(current) + "\n"
|
contents = "\n".join(current) + "\n"
|
||||||
|
|
||||||
with open(dst_path, "w") as f:
|
with open(dst_path, "w") as f:
|
||||||
|
Reference in New Issue
Block a user