summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-05-03 11:04:28 +0300
committerGuido Günther <agx@sigxcpu.org>2013-10-31 19:17:21 +0100
commit91fbdc17c8f529f649db7521f85a39e99d0cc4a4 (patch)
tree326f36aa809b78035b1bbae4326f347a601f60ae /gbp
parenta0d6eb7da045c5bc28bc0f2f6350aea4a0608d3f (diff)
pq: support patch-export commands
Support giving commands to pq as a meta tag in commit message. The format is "Gbp: <command> [args]". Currently, only one command is supported. namely 'ignore'. That is, one can use 'Gbp: Ignore' in the commit message for ignoring the commit in patch-generation. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/scripts/common/pq.py23
-rwxr-xr-xgbp/scripts/pq.py13
2 files changed, 32 insertions, 4 deletions
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
index 050e7df..b6b2118 100644
--- a/gbp/scripts/common/pq.py
+++ b/gbp/scripts/common/pq.py
@@ -68,6 +68,29 @@ def pq_branch_base(pq_branch):
return pq_branch[len(PQ_BRANCH_PREFIX):]
+def parse_gbp_commands(info, cmd_tag, noarg_cmds, arg_cmds):
+ """Parse gbp commands from commit message"""
+ cmd_re = re.compile(r'^%s:\s*(?P<cmd>[a-z-]+)(\s+(?P<args>\S.*))?' %
+ cmd_tag, flags=re.I)
+ commands = {}
+ for line in info['body'].splitlines():
+ match = re.match(cmd_re, line)
+ if match:
+ cmd = match.group('cmd').lower()
+ if arg_cmds and cmd in arg_cmds:
+ if match.group('args'):
+ commands[cmd] = match.group('args')
+ else:
+ gbp.log.warn("Ignoring gbp-command '%s' in commit %s: "
+ "missing cmd arguments" % (line, info['id']))
+ elif noarg_cmds and cmd in noarg_cmds:
+ commands[cmd] = match.group('args')
+ else:
+ gbp.log.warn("Ignoring unknow gbp-command '%s' in commit %s"
+ % (line, info['id']))
+ return commands
+
+
def patch_path_filter(file_status, exclude_regex=None):
"""
Create patch include paths, i.e. a "negation" of the exclude paths.
diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py
index c0f0946..f5618ce 100755
--- a/gbp/scripts/pq.py
+++ b/gbp/scripts/pq.py
@@ -30,8 +30,9 @@ from gbp.errors import GbpError
import gbp.log
from gbp.patch_series import (PatchSeries, Patch)
from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base,
- format_patch, switch_to_pq_branch,
- apply_single_patch, apply_and_commit_patch,
+ parse_gbp_commands, format_patch,
+ switch_to_pq_branch, apply_single_patch,
+ apply_and_commit_patch,
drop_pq, get_maintainer_from_control)
PATCH_DIR = "debian/patches/"
@@ -53,8 +54,12 @@ def generate_patches(repo, start, end, outdir, options):
topic_regex = 'gbp-pq-topic:\s*(?P<topic>\S.*)'
for commit in rev_list:
info = repo.get_commit_info(commit)
- format_patch(outdir, repo, info, patches, options.patch_numbers,
- topic_regex=topic_regex)
+ cmds = parse_gbp_commands(info, 'gbp', ('ignore'), None)
+ if not 'ignore' in cmds:
+ format_patch(outdir, repo, info, patches, options.patch_numbers,
+ topic_regex=topic_regex)
+ else:
+ gbp.log.info('Ignoring commit %s' % info['id'])
return patches