From 22d4b62d032894cec48cd725b42962291af63abf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Thu, 3 Mar 2011 09:38:39 +0100 Subject: [PATCH] gbp-pq: move write_patches into separate function Git-Dch: Ignore --- gbp-pq | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/gbp-pq b/gbp-pq index a262398..2498b69 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.+)") @@ -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: -- 2.7.4