blob: ece33850273b05decc1dbf18f246be1e465a0193 (
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
30
31
32
33
34
35
36
|
#!/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
git branch -D pre-generated.tmp &>/dev/null || true
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)"
make -j1
echo '!/out/' >> .gitignore
git add .
git commit -m "make: $msg"
git checkout pre-generated
git checkout pre-generated.tmp
git merge --no-edit -s ours pre-generated
git checkout pre-generated
git merge pre-generated.tmp
git branch -d pre-generated.tmp
)
rm -rf -- "$workdir"
git worktree prune
fi
|