Files
snapd/.precommit

33 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -e
echo "$@"
# put me in the project root, call me ".precommit".
# And put this here-document in ~/.bazaar/plugins/precommit_script.py:
<<EOF
import os
if not os.getenv("SKIP_COMMIT_HOOK"):
import subprocess
from bzrlib.mutabletree import MutableTree
from bzrlib import errors
def start_commit_hook(*_):
"""This hook will execute '.precommit' script from root path of the bazaar
branch. Commit will be canceled if precommit fails."""
# this hook only makes sense if a precommit file exist.
if not os.path.exists(".precommit"):
return
try:
subprocess.check_call(os.path.abspath(".precommit"))
# if precommit fails (process return not zero) cancel commit.
except subprocess.CalledProcessError:
raise errors.BzrError("pre commit check failed (set SKIP_COMMIT_HOOK to skip).")
MutableTree.hooks.install_named_hook('start_commit', start_commit_hook,
'Run "precommit" script on start_commit')
EOF
./run-checks --quick