~unity-team/ubuntu-ui-toolkit/dynamic-grid-unit

« back to all changes in this revision

Viewing changes to .bazaar/plugins/packaging_sorting.py

  • Committer: CI Train Bot
  • Author(s): Zoltán Balogh, Tim Peeters, Zsombor Egri, Christian Dywan, Andrea Bernabei
  • Date: 2016-04-12 11:12:39 UTC
  • mfrom: (1000.868.47 OTA11-landing-2016-04-08)
  • Revision ID: ci-train-bot@canonical.com-20160412111239-g60hc86tzxtrprn3
OTA11-landing-2016-04-08

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# Copyright 2016 Canonical Ltd.
 
3
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
#
 
16
# Author: Timo Jyrinki <timo.jyrinki@canonical.com>
 
17
 
 
18
from bzrlib import branch
 
19
from bzrlib import errors
 
20
import os
 
21
import subprocess
 
22
 
 
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"""
 
26
 
 
27
    if (master.get_parent().find("ubuntu-ui-toolkit") == -1):
 
28
        return
 
29
 
 
30
    if not os.path.exists("/usr/bin/wrap-and-sort"):
 
31
      raise errors.BzrError("Please install 'devscripts' package.")
 
32
      return
 
33
 
 
34
    subprocess.call(["cp", "-a", "debian", "debian-packaging-wraptest-temporary"])
 
35
 
 
36
    subprocess.call(["wrap-and-sort", "-a", "-t"])
 
37
 
 
38
    returncode = subprocess.call(["diff", "-urN",
 
39
        "debian-packaging-wraptest-temporary", "debian"])
 
40
    if returncode == 1:
 
41
      subprocess.call(["rm", "-rf", "debian-packaging-wraptest-temporary"])
 
42
      raise errors.BzrError("Please run wrap-and-sort -a -t to clean up packaging.")
 
43
 
 
44
    subprocess.call(["rm", "-rf", "debian-packaging-wraptest-temporary"])
 
45
 
 
46
branch.Branch.hooks.install_named_hook("pre_commit", pre_commit_hook, "Check packaging sorting")