blob: 1a3aa99f22486fa40a771aa5c1266d2abf1c09c1 (
plain) (
blame)
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
|
#!/bin/sh
# Vendor git-forge's source into forge/ for the image build. Derived state:
# gitignored, and running this again replaces it.
#
# GIT_FORGE_SRC where to take it from, default ../git-forge
# GIT_FORGE_REV which commit, default the one in forge.rev
set -eu
src="${GIT_FORGE_SRC:-../git-forge}"
rev="${GIT_FORGE_REV:-$(cat forge.rev)}"
# Resolved before anything is removed, so a revision that is not there fails
# with the tree that was vendored last still in place. --verify, because plain
# rev-parse echoes a forty character sha back without looking for it.
sha=$(git -C "$src" rev-parse --verify "$rev^{commit}")
# Into a file rather than a pipe: a pipeline exits with the status of its last
# command, so a failed archive would be an empty forge/ and an exit of zero.
archive=$(mktemp)
trap 'rm -f "$archive"' EXIT
git -C "$src" archive -o "$archive" "$sha"
rm -rf forge
mkdir forge
tar -xf "$archive" -C forge
echo "$sha" >forge/.rev
echo "vendored git-forge $sha from $src"
|