aboutsummarylogtreecommitdiffstats
path: root/pre-commit.sh
blob: 8d0f65983bff90574f35ffabcedf4f7f6df46784 (plain)
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
#!/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
updpkgsums

# Remove the archive downloaded by updpkgsums
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"
fi