summaryrefslogtreecommitdiff
path: root/post-commit
blob: b8f816abcfc8da032132bfc04570b08001f96cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
# Copyright 2016-2017 Luke Shumaker
set -e

branch=$(git name-rev --name-only HEAD)
if [[ $branch == master ]]; then
	gitdir="$(git rev-parse --git-dir)"
	workdir="${gitdir}/pre-generated"
	exec 8>"${workdir}.lock"
	flock 8

	rm -rf -- "$workdir"
	git worktree prune

	unset GIT_INDEX_FILE
	git worktree add "${gitdir}/pre-generated" pre-generated
	(
		unset GIT_DIR GIT_WORK_TREE
		cd "$workdir"

		git merge master -m 'bogus'
		make --always-make -j12
		git add .
		git commit --amend -m "make: $(git log -n1 master --pretty=format:%B)"
	)

	rm -rf -- "$workdir"
	git worktree prune
fi