From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, "David Kågedal" <davidk@lysator.liu.se>
Subject: [StGit PATCH 1/5] Added --save-template flag to edit command
Date: Fri, 14 Dec 2007 07:25:03 +0100 [thread overview]
Message-ID: <20071214062503.29148.84674.stgit@yoghurt> (raw)
In-Reply-To: <20071214062251.29148.86191.stgit@yoghurt>
From: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/edit.py | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index a4d8f96..ec2c4ae 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -72,6 +72,8 @@ options = [make_option('-d', '--diff',
help = 'annotate the patch log entry'),
make_option('-m', '--message',
help = 'replace the patch description with MESSAGE'),
+ make_option('--save-template', metavar = 'FILE',
+ help = 'save the patch to FILE in the format used by -f'),
make_option('--author', metavar = '"NAME <EMAIL>"',
help = 'replae the author details with "NAME <EMAIL>"'),
make_option('--authname',
@@ -120,8 +122,8 @@ def __update_patch(pname, fname, options):
else:
out.done()
-def __edit_update_patch(pname, options):
- """Edit the given patch interactively.
+def __generate_file(pname, fname, options):
+ """Generate a file containing the description to edit
"""
patch = crt_series.get_patch(pname)
@@ -168,15 +170,20 @@ def __edit_update_patch(pname, options):
text = tmpl % tmpl_dict
+ # write the file to be edited
+ f = open(fname, 'w+')
+ f.write(text)
+ f.close()
+
+def __edit_update_patch(pname, options):
+ """Edit the given patch interactively.
+ """
if options.diff:
fname = '.stgit-edit.diff'
else:
fname = '.stgit-edit.txt'
- # write the file to be edited
- f = open(fname, 'w+')
- f.write(text)
- f.close()
+ __generate_file(pname, fname, options)
# invoke the editor
call_editor(fname)
@@ -233,6 +240,8 @@ def func(parser, options, args):
log = 'edit',
notes = options.annotate)
out.done()
+ elif options.save_template:
+ __generate_file(pname, options.save_template, options)
elif options.file:
__update_patch(pname, options.file, options)
else:
next prev parent reply other threads:[~2007-12-14 6:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 6:24 [StGit PATCH 0/5] Various odds and ends Karl Hasselström
2007-12-14 6:25 ` Karl Hasselström [this message]
2007-12-14 6:25 ` [StGit PATCH 2/5] Treat filename '-' as stdin/stdout in edit Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 3/5] Let parse_patch take a string instead of a file parameter Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 4/5] Make generic --message/--file/--save-template flags Karl Hasselström
2007-12-14 6:44 ` Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 5/5] Name the exit codes to improve legibility Karl Hasselström
2007-12-14 6:45 ` Karl Hasselström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071214062503.29148.84674.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=davidk@lysator.liu.se \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).