-
Notifications
You must be signed in to change notification settings - Fork 6
/
generate
executable file
·35 lines (31 loc) · 901 Bytes
/
generate
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
#!/bin/sh
#/ script/generate runs all generators for this repo.
#/ `script/generate --check` checks that the generated files are up to date.
set -e
CDPATH="" cd -- "$(dirname -- "$0")/.."
if [ "$1" = "--check" ]; then
GENTEMP="$(mktemp -d)"
git worktree add -q --detach "$GENTEMP"
trap 'git worktree remove -f "$GENTEMP"; rm -rf "$GENTEMP"' EXIT
for f in $(git ls-files -com --exclude-standard); do
target="$GENTEMP/$f"
mkdir -p "$(dirname -- "$target")"
cp "$f" "$target"
done
if [ -f "$(pwd)"/bin ]; then
ln -s "$(pwd)"/bin "$GENTEMP"/bin
fi
(
cd "$GENTEMP"
git add .
git -c user.name='bot' -c user.email='bot@localhost' commit -m "generate" -q --allow-empty
script/generate
[ -z "$(git status --porcelain)" ] || {
echo "script/generate resulted in changes." 1>&2
git diff
exit 1
}
)
exit 0
fi
script/generate-readme