Skip to content

Commit b4dbb3d

Browse files
authored
Do not commit release artefacts by default (#1183)
We add a `-r`, `--commit-artefacts` option to the `seed` command. When that option is enabled, we commit the release assets from the very first build into the repository (assuming that `--skip-git` is _not_ used; under `--skip-git`, we are never committing anything no matter what). Adding the release assets to the repository is done directly from within the `seed` command, which allows us to remove the `prepare_initial_release` target from the standard Makefile (that target was only ever needed by the `seed` command). But we do add instead a small helper target, `show_release_assets`, that the `seed` command is using to get the list of the assets to commit. In .gitignore, we unconditionally ignore the top-level release artefacts, so that they can never be committed inadvertently. If the user chooses to commit release artefacts at commit time (using the `--commit-artefacts` option), the `seed` command will forcefully add the artefacts so that Git will start tracking them anyway. closes #1144
1 parent 7e66a1c commit b4dbb3d

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

odk/odk.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,9 @@ def update(templatedir):
11551155
@click.option('-g', '--skipgit', default=False, is_flag=True)
11561156
@click.option('-n', '--gitname', default=None)
11571157
@click.option('-e', '--gitemail', default=None)
1158+
@click.option('-r', '--commit-artefacts', default=False, is_flag=True)
11581159
@click.argument('repo', nargs=-1)
1159-
def seed(config, clean, outdir, templatedir, dependencies, title, user, source, verbose, repo, skipgit, gitname, gitemail):
1160+
def seed(config, clean, outdir, templatedir, dependencies, title, user, source, verbose, repo, skipgit, gitname, gitemail, commit_artefacts):
11601161
"""
11611162
Seeds an ontology project
11621163
"""
@@ -1213,10 +1214,18 @@ def seed(config, clean, outdir, templatedir, dependencies, title, user, source,
12131214
if gitemail is not None:
12141215
os.environ['GIT_AUTHOR_EMAIL'] = gitemail
12151216
os.environ['GIT_COMMITTER_EMAIL'] = gitemail
1216-
runcmd("cd {dir} && git init && git add {files}".
1217+
runcmd("cd {dir} && git init -b {branch} && git add {files} && git commit -m 'initial commit'".
12171218
format(dir=outdir,
1219+
branch=project.git_main_branch,
12181220
files=" ".join([t.replace(outdir, ".", 1) for t in tgts])))
1219-
runcmd("cd {dir}/src/ontology && make && git commit -m 'initial commit' -a && git branch -M {branch} && make prepare_initial_release && git commit -m 'first release'".format(dir=outdir, branch=project.git_main_branch))
1221+
runcmd("cd {dir}/src/ontology && make all_assets && cp $(make show_release_assets) ../../"
1222+
.format(dir=outdir))
1223+
if commit_artefacts:
1224+
runcmd("cd {dir}/src/ontology "
1225+
"&& for asset in $(make show_release_assets) ; do git add -f ../../$asset ; done"
1226+
.format(dir=outdir))
1227+
runcmd("cd {dir} && if [ -n \"$(git status -s)\" ]; then git commit -a -m 'initial build' ; fi"
1228+
.format(dir=outdir))
12201229
print("\n\n####\nNEXT STEPS:")
12211230
print(" 0. Examine {} and check it meets your expectations. If not blow it away and start again".format(outdir))
12221231
print(" 1. Go to: https://github.com/new")
@@ -1227,7 +1236,6 @@ def seed(config, clean, outdir, templatedir, dependencies, title, user, source,
12271236
print(" E.g.:")
12281237
print("cd {}".format(outdir))
12291238
print("git remote add origin git@github.com:{org}/{repo}.git".format(org=project.github_org, repo=project.repo))
1230-
print("git branch -M {branch}\n".format(branch=project.git_main_branch))
12311239
print("git push -u origin {branch}\n".format(branch=project.git_main_branch))
12321240
print("BE BOLD: you can always delete your repo and start again\n")
12331241
print("")

template/.gitignore.jinja2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ bin/
1111

1212
.github/token.txt
1313

14+
/{{ project.id }}.owl
15+
/{{ project.id }}.obo
16+
/{{ project.id }}.json
17+
/{{ project.id }}.db
18+
/{{ project.id }}-base.*
19+
/{{ project.id }}-basic.*
20+
/{{ project.id }}-full.*
21+
/{{ project.id }}-simple.*
22+
/{{ project.id }}-simple-non-classified.*
23+
1424
src/ontology/mirror
1525
src/ontology/mirror/*
1626
src/ontology/reports/*

template/src/ontology/Makefile.jinja2

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ show_assets:
400400
echo $(ASSETS)
401401
du -sh $(ASSETS)
402402

403+
.PHONY: show_release_assets
404+
show_release_assets:
405+
@echo $(RELEASE_ASSETS)
406+
403407
check_rdfxml_%: %
404408
@check-rdfxml {% if project.extra_rdfxml_checks %}--jena --rdflib{% endif %} $<
405409

@@ -427,14 +431,6 @@ prepare_release: all_odk
427431
echo "Release files are now in $(RELEASEDIR) - now you should commit, push and make a release \
428432
on your git hosting site such as GitHub or GitLab"
429433

430-
.PHONY: prepare_initial_release
431-
prepare_initial_release: all_assets
432-
rsync -R $(RELEASE_ASSETS) $(RELEASEDIR) &&\{% if project.sssom_mappingset_group is defined %}{% if project.sssom_mappingset_group.released_products is defined %}
433-
mkdir -p $(RELEASEDIR)/mappings && cp -rf $(RELEASED_MAPPING_FILES) $(RELEASEDIR)/mappings &&\{% endif %}{% endif %}{% if project.use_dosdps %}
434-
mkdir -p $(RELEASEDIR)/patterns && cp -rf $(PATTERN_RELEASE_FILES) $(RELEASEDIR)/patterns &&\{% endif %}
435-
rm -f $(patsubst %, ./%, $(CLEANFILES)) &&\
436-
cd $(RELEASEDIR) && git add $(RELEASE_ASSETS)
437-
438434
.PHONY: prepare_release_fast
439435
prepare_release_fast:
440436
$(MAKE) prepare_release IMP=false PAT=false MIR=false COMP=false

0 commit comments

Comments
 (0)