From 23a88c7d79f3cec8ff330304894c249090278052 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 28 Jul 2005 16:57:09 +0100 Subject: [PATCH] 'export' to use the global template file If there is no .git/patchexport.tmpl file, use the default one in /usr/share/stgit/templates Signed-off-by: Catalin Marinas --- stgit/commands/export.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/stgit/commands/export.py b/stgit/commands/export.py index 40f1a48f..ebcc77a2 100644 --- a/stgit/commands/export.py +++ b/stgit/commands/export.py @@ -30,9 +30,11 @@ help = 'exports a series of patches to (or patches)' usage = """%prog [options] [] Export the applied patches into a given directory (defaults to -'patches') in a standard unified GNU diff format. A file (defaulting -to '.git/patchexport.tmpl') can be used as a template for the patch -format. The following variables are supported in the template file: +'patches') in a standard unified GNU diff format. A template file +(defaulting to '.git/patchexport.tmpl or +/usr/share/stgit/templates/patchexport.tmpl') can be used for the +patch format. The following variables are supported in the template +file: %(description)s - patch description %(diffstat)s - the diff statistics @@ -114,6 +116,21 @@ def func(parser, options, args): if zpadding < 2: zpadding = 2 + # get the template + if options.template: + patch_tmpl_list = [options.template] + else: + patch_tmpl_list = [] + + patch_tmpl_list += [os.path.join(git.base_dir, 'patchexport.tmpl'), + os.path.join(sys.prefix, + 'share/stgit/templates/patchexport.tmpl')] + tmpl = '' + for patch_tmpl in patch_tmpl_list: + if os.path.isfile(patch_tmpl): + tmpl = file(patch_tmpl).read() + break + patch_no = 1; for p in patches: pname = p @@ -124,16 +141,6 @@ def func(parser, options, args): pfile = os.path.join(dirname, pname) print >> series, pname - # get the template - if options.template: - patch_tmpl = options.template - else: - patch_tmpl = os.path.join(git.base_dir, 'patchexport.tmpl') - if os.path.isfile(patch_tmpl): - tmpl = file(patch_tmpl).read() - else: - tmpl = '' - # get the patch description patch = crt_series.get_patch(p) -- 2.11.4.GIT