aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp-pq
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-03-03 09:38:39 +0100
committerGuido Günther <agx@sigxcpu.org>2011-03-12 21:38:04 +0100
commit22d4b62d032894cec48cd725b42962291af63abf (patch)
tree8030b860967c7c9d09563358157a731970f9c07c /gbp-pq
parent258743a8f767a75d6fdf10dcf0f0e23edb104493 (diff)
gbp-pq: move write_patches into separate function
Git-Dch: Ignore
Diffstat (limited to 'gbp-pq')
-rwxr-xr-xgbp-pq33
1 files changed, 20 insertions, 13 deletions
diff --git a/gbp-pq b/gbp-pq
index a262398a..2498b692 100755
--- a/gbp-pq
+++ b/gbp-pq
@@ -48,6 +48,24 @@ def pq_branch_base(pq_branch):
if is_pq_branch(pq_branch):
return pq_branch[len(PQ_BRANCH_PREFIX):]
+
+def write_patch(patch, options)
+ # delete the first line (from sha1) and last two lines (git version
+ # info) of the patch file
+ Command("sed -i -e '1d' -e 'N;$!P;$!D;$d' %s" % patch, shell=True)()
+ Command("sed -i -e 's/^-- \\n[0-9\.]+$//' %s" % patch, shell=True)()
+
+ name = patch[len(PATCH_DIR):]
+ if not options.patch_numbers:
+ m = patch_re.match(name)
+ if m:
+ filename = m.group('name')
+ shutil.move(patch, os.path.join(PATCH_DIR, filename))
+ else:
+ filename = name
+ return filename
+
+
def export_patches(repo, branch, options):
patch_re = re.compile("[0-9]+-(?P<name>.+)")
@@ -71,19 +89,8 @@ def export_patches(repo, branch, options):
f = file(SERIES_FILE, 'w')
gbp.log.info("Regenerating patch queue in '%s'." % PATCH_DIR)
for patch in patches:
- # delete the first line (from sha1) and last two lines (git version
- # info) of the patch file
- Command("sed -i -e '1d' -e 'N;$!P;$!D;$d' %s" % patch, shell=True)()
- Command("sed -i -e 's/^-- \\n[0-9\.]+$//' %s" % patch, shell=True)()
-
- name = patch[len(PATCH_DIR):]
- if not options.patch_numbers:
- m = patch_re.match(name)
- if m:
- name = m.group('name')
- shutil.move(patch, os.path.join(PATCH_DIR, name))
-
- f.write(name + '\n')
+ filename = write_patch(patch, options)
+ f.write(filename + '\n')
f.close()
GitCommand('status')(['--', PATCH_DIR])
else: