-
Notifications
You must be signed in to change notification settings - Fork 2
/
pre-commit
executable file
·37 lines (30 loc) · 964 Bytes
/
pre-commit
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
37
#!/bin/bash
# Originally writtten by Stefans Mezulis <[email protected]> for
# https://github.com/pipeseroni/packaging-aur
# Released into the public domain via the CC0 waiver.
# Only check package branches.
branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "$branch" != "pipes"* ]]; then
exit 0
fi
root_dir=$(git rev-parse --show-toplevel)
cd "$root_dir"
# Read hashes from existing PKGBUILD
source ./PKGBUILD
pkgbuild_hashes=(${sha256sums[@]})
# Get actual hashes according to makepkg
eval $(makepkg -g)
actual_hashes=(${sha256sums[@]})
# Compare the hashes
diff_output=$(diff -u \
--label PKGBUILD --label actual \
<(printf "%s\n" "${pkgbuild_hashes[@]}") \
<(printf "%s\n" "${actual_hashes[@]}"))
if [[ $? != 0 ]]; then
printf "PKGBUILD hashes do not match actual hashes. Diff:\n" >&2
printf "%s\n" "$diff_output" >&2
exit 1
fi
# Update .SRCINFO before each commit.
makepkg --printsrcinfo > .SRCINFO
git add ./.SRCINFO