forked from platformio/platformio-core
Don't override existing ".gitignore" file
This commit is contained in:
@ -100,6 +100,9 @@ def cli(
|
|||||||
pg = ProjectGenerator(project_dir, ide, env_name)
|
pg = ProjectGenerator(project_dir, ide, env_name)
|
||||||
pg.generate()
|
pg.generate()
|
||||||
|
|
||||||
|
init_ci_conf(project_dir)
|
||||||
|
init_cvs_ignore(project_dir)
|
||||||
|
|
||||||
if silent:
|
if silent:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -148,9 +151,6 @@ def init_base_project(project_dir):
|
|||||||
join(util.get_source_dir(), "projectconftpl.ini"),
|
join(util.get_source_dir(), "projectconftpl.ini"),
|
||||||
join(project_dir, "platformio.ini"))
|
join(project_dir, "platformio.ini"))
|
||||||
|
|
||||||
init_ci_conf(project_dir)
|
|
||||||
init_cvs_ignore(project_dir)
|
|
||||||
|
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
dir_to_readme = [
|
dir_to_readme = [
|
||||||
(util.get_projectsrc_dir(), None),
|
(util.get_projectsrc_dir(), None),
|
||||||
@ -278,7 +278,10 @@ More information about PIO Unit Testing:
|
|||||||
|
|
||||||
|
|
||||||
def init_ci_conf(project_dir):
|
def init_ci_conf(project_dir):
|
||||||
with open(join(project_dir, ".travis.yml"), "w") as f:
|
conf_path = join(project_dir, ".travis.yml")
|
||||||
|
if isfile(conf_path):
|
||||||
|
return
|
||||||
|
with open(conf_path, "w") as f:
|
||||||
f.write("""# Continuous Integration (CI) is the practice, in software
|
f.write("""# Continuous Integration (CI) is the practice, in software
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
# engineering, of merging all developer working copies with a shared mainline
|
||||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||||
@ -350,23 +353,11 @@ def init_ci_conf(project_dir):
|
|||||||
|
|
||||||
|
|
||||||
def init_cvs_ignore(project_dir):
|
def init_cvs_ignore(project_dir):
|
||||||
ignore_path = join(project_dir, ".gitignore")
|
conf_path = join(project_dir, ".gitignore")
|
||||||
default = [".pioenvs\n", ".piolibdeps\n"]
|
if isfile(conf_path):
|
||||||
current = []
|
|
||||||
modified = False
|
|
||||||
if isfile(ignore_path):
|
|
||||||
with open(ignore_path) as fp:
|
|
||||||
current = fp.readlines()
|
|
||||||
if current and not current[-1].endswith("\n"):
|
|
||||||
current[-1] += "\n"
|
|
||||||
for d in default:
|
|
||||||
if d not in current:
|
|
||||||
modified = True
|
|
||||||
current.append(d)
|
|
||||||
if not modified:
|
|
||||||
return
|
return
|
||||||
with open(ignore_path, "w") as fp:
|
with open(conf_path, "w") as fp:
|
||||||
fp.writelines(current)
|
fp.writelines([".pio\n", ".pioenvs\n", ".piolibdeps\n"])
|
||||||
|
|
||||||
|
|
||||||
def fill_project_envs(ctx, project_dir, board_ids, project_option, env_prefix,
|
def fill_project_envs(ctx, project_dir, board_ids, project_option, env_prefix,
|
||||||
|
@ -127,24 +127,8 @@ class ProjectGenerator(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _merge_contents(dst_path, contents):
|
def _merge_contents(dst_path, contents):
|
||||||
file_name = basename(dst_path)
|
if basename(dst_path) == ".gitignore" and isfile(dst_path):
|
||||||
|
return
|
||||||
# merge .gitignore
|
|
||||||
if file_name == ".gitignore":
|
|
||||||
if not isfile(dst_path):
|
|
||||||
return
|
|
||||||
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:
|
with open(dst_path, "w") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user