Development using git:Quality assurance

From Alpine Linux
Revision as of 09:08, 15 November 2012 by Ncopa (talk | contribs) (Add a git hook to catch common errors early)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

  • The package actually builds
  • Commit message is good
  • pkgrel is bumped if needed
  • no whitespace damage (last chars of a line is whitespace)

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


# Redirect output to stderr.
exec 1>&2

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

# 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.