From 18ffed0c8baf19b53a26b23490c5f4e2367ea398 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 10 Feb 2017 18:42:31 -0500 Subject: Improve post-commit tooling --- bin/pre-generate | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bin/pre-generate') diff --git a/bin/pre-generate b/bin/pre-generate index e5f8f5e..c2d3516 100755 --- a/bin/pre-generate +++ b/bin/pre-generate @@ -13,23 +13,38 @@ if [[ $branch == master ]]; then git worktree prune git branch -D pre-generated.tmp &>/dev/null || true + unset GIT_INDEX_FILE git worktree add -b pre-generated.tmp "${gitdir}/pre-generated" master ( unset GIT_DIR GIT_WORK_TREE cd "$workdir" + msg="$(git log -n1 master --pretty=format:%B)" + export GIT_AUTHOR_NAME='Maker' + export GIT_AUTHOR_EMAIL='maker@andrewdm.me' make -j1 echo '!/out/' >> .gitignore git add . git commit -m "make: $msg" - git checkout pre-generated + + git checkout pre-generated # Ensure it exists locally + git pull --no-edit -s ours # Avoid conflicts + + # What we want is + # + # git merge --no-edit -s theirs pre-generated.tmp + # + # Unfortunately, there is no 'theirs' strategy; so we + # have to switch branches and do it backward with the + # 'ours' strategry, switch back, then merge the merge + # commit. git checkout pre-generated.tmp git merge --no-edit -s ours pre-generated git checkout pre-generated - git pull git merge pre-generated.tmp + git branch -d pre-generated.tmp ) rm -rf -- "$workdir" -- cgit v1.2.3-54-g00ecf