aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDany Marcoux2016-10-06 23:35:35 +0200
committerDany Marcoux2016-10-06 23:35:35 +0200
commit78723288f668ade833afe6f2757d53eb46dae201 (patch)
tree1d9822ad5774bc72639a5ff7c40d6fb96d9bccfe
parent9fd184b7ccf71ba8033fa74d3f2032cdf407960e (diff)
downloadaur-78723288f668ade833afe6f2757d53eb46dae201.tar.gz
Improve git pre-commit hook
-rwxr-xr-xpre-commit.sh28
1 files changed, 13 insertions, 15 deletions
diff --git a/pre-commit.sh b/pre-commit.sh
index 8d0f65983bff..2663b34cdba0 100755
--- a/pre-commit.sh
+++ b/pre-commit.sh
@@ -1,18 +1,7 @@
#!/bin/bash
# git pre-commit hook:
-# - Generate the .SRCINFO file and add it to the commit if it changed
-# - Generate the sha256sums in the PKGBUILD file and add it to the commit if it changed
-
-# Generate the .SRCINFO file based on the PKGBUILD file
-mksrcinfo
-
-# Check if the .SRCINFO file changed
-if [ -n "$(git diff --name-only | grep '^.SRCINFO$')" ]; then
- printf "Updated the .SRCINFO file\n"
- git diff .SRCINFO
- git add .SRCINFO
- printf "\nAdded the .SRCINFO file to the commit\n"
-fi
+# - Generate the sha256sums in the PKGBUILD file and add it to the commit if needed
+# - Generate the .SRCINFO file and add it to the commit if needed
# Generate the sha256sums in the PKGBUILD file
updpkgsums
@@ -23,7 +12,16 @@ rm *.tar.gz
# Check if the sha256sums in the PKGBUILD file changed
if [ -n "$(git diff PKGBUILD | grep '^+sha256sums=(.*)$')" ]; then
printf "Updated the sha256sums in the PKGBUILD file\n"
- git diff PKGBUILD
git add PKGBUILD
- printf "\nAdded the PKGBUILD file to the commit\n"
+ printf "Added the PKGBUILD file to the commit\n"
+fi
+
+# Generate the .SRCINFO file based on the PKGBUILD file
+mksrcinfo
+
+# Check if the .SRCINFO file was created/changed
+if [ -n "$(git status --short | grep ' .SRCINFO$')" ]; then
+ printf "Updated the .SRCINFO file\n"
+ git add .SRCINFO
+ printf "Added the .SRCINFO file to the commit\n"
fi