~chipaca/ubuntu-push/gsettings

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/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
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.")

MutableTree.hooks.install_named_hook('start_commit', start_commit_hook,
                                     'Run "precommit" script on start_commit')
EOF

make check-format # or whatever