forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.precommit
executable file
·32 lines (26 loc) · 1.06 KB
/
.precommit
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
30
31
#!/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