Development using git:Quality assurance: Difference between revisions

From Alpine Linux
m (changed unnumberedd list to numbered list)
("sanitycheck" is obsolete, use "validate" instead)
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
         olddir=$PWD
         olddir=$PWD
         cd ${f%/APKBUILD}
         cd ${f%/APKBUILD}
         if ! abuild sanitycheck && verify; then
         if ! abuild validate && verify; then
                 exit 1
                 exit 1
         fi
         fi
Line 26: Line 26:


Install it as .git/hooks/pre-commit and make it executable.
Install it as .git/hooks/pre-commit and make it executable.
= See Also =
*[[Development using git]]


[[Category:Development]]
[[Category:Development]]
[[Category:Git]]
[[Category:Git]]

Latest revision as of 18:59, 29 October 2025

Before pushing anything to it is good to make sure that:

  1. The package actually builds
  2. Commit message is good
  3. pkgrel is bumped if needed
  4. no whitespace damage (last chars of a line is whitespace)

The following git hook will help you catch some common errors early:

#!/bin/sh

# Redirect output to stderr.
exec 1>&2

git diff --cached --name-only HEAD | grep 'APKBUILD$' | while read f; do
        olddir=$PWD
        cd ${f%/APKBUILD}
        if ! abuild validate && verify; then
                exit 1
        fi
        cd "$olddir"
done

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached HEAD --

Install it as .git/hooks/pre-commit and make it executable.