diff --git a/platformio/commands/init.py b/platformio/commands/init.py index aebd3bea..3dc454be 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -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) diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index aee32748..5e4b0e8f 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -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: