diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-04-05 14:31:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-04-05 14:31:19 -0400 |
commit | 118f0016d2f1ecece4d282a257049a86bc4c9ca6 (patch) | |
tree | 2f1cee9cea47b39634de320289f7ad0bc8b2d5b0 /etckeeper-bzr | |
parent | fa84e9dcae169c7e6f9800572cb94bad2c09c51e (diff) |
Include etckeeper plugin in Debian package.
Conflicts:
debian/control
Diffstat (limited to 'etckeeper-bzr')
-rwxr-xr-x | etckeeper-bzr/__init__.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/etckeeper-bzr/__init__.py b/etckeeper-bzr/__init__.py new file mode 100755 index 0000000..a5381c5 --- /dev/null +++ b/etckeeper-bzr/__init__.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# Bazaar plugin that runs etckeeper pre-commit when necessary + +"""Runs etckeeper pre-commit when necessary.""" + +import bzrlib +from bzrlib.mutabletree import MutableTree +from bzrlib.errors import BzrError, NotLocalUrl +import os +import subprocess + +if bzrlib.version_info[:2] < (1,4): + raise "Version of Bazaar to old. Need at least 1.4." + +def etckeeper_startcommit_hook(tree): + if not os.path.exists(tree.abspath(".etckeeper")): + # Only run the commit hook when this is an etckeeper branch + return + ret = subprocess.call(["etckeeper", "pre-commit", tree.abspath(".")]) + if ret != 0: + raise BzrError("etckeeper pre-commit failed") + +MutableTree.hooks.install_hook('start_commit', etckeeper_startcommit_hook) +MutableTree.hooks.name_hook(etckeeper_startcommit_hook, "etckeeper") + +if __name__ == "__main__": + from distutils.core import setup + setup(name="bzr-etckeeper", + packages=["bzrlib.plugins.etckeeper"], + package_dir={"bzrlib.plugins.etckeeper":"etckeeper-bzr"}) |