2
# Copyright 2016 Canonical Ltd.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU Lesser General Public License as published by
6
# the Free Software Foundation; version 3.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Lesser General Public License for more details.
13
# You should have received a copy of the GNU Lesser General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# Author: Timo Jyrinki <timo.jyrinki@canonical.com>
18
from bzrlib import branch
19
from bzrlib import errors
23
def pre_commit_hook(local, master, old_revno, old_revid, future_revno,
24
future_revid, tree_delta, future_tree):
25
"""Ensure packaging has gone through wrap-and-sort command"""
27
if (master.get_parent().find("ubuntu-ui-toolkit") == -1):
30
if not os.path.exists("/usr/bin/wrap-and-sort"):
31
raise errors.BzrError("Please install 'devscripts' package.")
34
subprocess.call(["cp", "-a", "debian", "debian-packaging-wraptest-temporary"])
36
subprocess.call(["wrap-and-sort", "-a", "-t"])
38
returncode = subprocess.call(["diff", "-urN",
39
"debian-packaging-wraptest-temporary", "debian"])
41
subprocess.call(["rm", "-rf", "debian-packaging-wraptest-temporary"])
42
raise errors.BzrError("Please run wrap-and-sort -a -t to clean up packaging.")
44
subprocess.call(["rm", "-rf", "debian-packaging-wraptest-temporary"])
46
branch.Branch.hooks.install_named_hook("pre_commit", pre_commit_hook, "Check packaging sorting")