Fix merging of ".gitignore" files when re-initialize project // Resolve #848

This commit is contained in:
Ivan Kravets
2016-12-07 00:14:47 +02:00
parent de4bec0a21
commit 22a272061f
5 changed files with 12 additions and 7 deletions

View File

@ -56,6 +56,8 @@ PlatformIO 3.0
(`issue #838 <https://github.com/platformio/platformio-core/issues/838>`_)
* Fixed unable to include SSH user in ``lib_deps`` repository url
(`issue #830 <https://github.com/platformio/platformio-core/issues/830>`_)
* Fixed merging of ".gitignore" files when re-initialize project
(`issue #848 <https://github.com/platformio/platformio-core/issues/848>`_)
* Fixed issue with ``PATH`` auto-configuring for upload tools
* Fixed ``99-platformio-udev.rules`` checker for Linux OS

View File

@ -127,13 +127,13 @@ class ProjectGenerator(object):
# merge .gitignore
if file_name == ".gitignore" and isfile(dst_path):
contents = [l.strip() for l in contents.split("\n") if l.strip()]
with open(dst_path) as f:
for line in f.readlines():
line = line.strip()
if line and line not in contents:
contents.append(line)
contents = "\n".join(contents)
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:
current.append(d)
contents = "\n".join(current) + "\n"
with open(dst_path, "w") as f:
f.write(contents)

View File

@ -1,3 +1,4 @@
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json

View File

@ -1,2 +1,3 @@
.pioenvs
.piolibdeps
CMakeListsPrivate.txt

View File

@ -1,2 +1,3 @@
.pioenvs
.piolibdeps
.clang_complete