-
Notifications
You must be signed in to change notification settings - Fork 18
/
prepare-commit-msg.hook
executable file
·39 lines (33 loc) · 1.28 KB
/
prepare-commit-msg.hook
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
38
39
#!/bin/bash
old_commit_msg="$(cat ${1})"
echo -n "" > "${1}"
# Check for new PKGBUILDs
for path in $(git diff --name-only --cached --diff-filter=A); do
if [[ "${path}" =~ .*/PKGBUILD$ ]]; then
(
source "${path}"
: ${pkgbase:=${pkgname}}
echo -e "Initial upload: ${pkgbase} ${epoch:+${epoch}:}${pkgver}-${pkgrel}\n" >> "${1}"
)
fi
done
# Check for updated PKGBUILDs
for path in $(git diff --name-only --cached --diff-filter=M); do
if [[ "${path}" =~ .*/PKGBUILD$ ]]; then
(
source "${path}"
: ${pkgbase:=${pkgname}}
echo -e "upgpkg: ${pkgbase} ${epoch:+${epoch}:}${pkgver}-${pkgrel}\n" >> "${1}"
# If the pkgrel is "1" and there is no VCS pkgver function (or there is one, but the git revision is "0"), assume a new version.
[[ $pkgver =~ .+\.r([0-9]+)\..+ ]]
[[ "${pkgrel}" = "1" && ( $(type -t pkgver) != "function" || ${BASH_REMATCH[1]} = 0 ) ]] && echo -e "upstream release\n" >> "${1}"
)
fi
done
# Check for deleted PKGBUILDs
for path in $(git diff --name-only --cached --diff-filter=D); do
if [[ "${path}" =~ .*/PKGBUILD$ ]]; then
echo -e "Deleted package: ${path%/PKGBUILD}\n" >> "${1}"
fi
done
echo "${old_commit_msg}" >> "${1}"