From 19cd0a8fe0cb7cfd0d5f784024014419ec354adf Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 14 Jul 2005 10:48:36 +0100 Subject: [PATCH] Add "name " parsing for simpler commands Signed-off-by: Catalin Marinas --- stgit/commands/common.py | 12 +++++++++++- stgit/commands/new.py | 5 +++++ stgit/commands/refresh.py | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/stgit/commands/common.py b/stgit/commands/common.py index d18b0b2..160dd37 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import sys, os +import sys, os, re from optparse import OptionParser, make_option from stgit.utils import * @@ -116,3 +116,13 @@ def resolved_all(): for filename in conflicts: resolved(filename) os.remove(os.path.join(git.base_dir, 'conflicts')) + +def name_email(string): + """Return a tuple consisting of the name and email parsed from a + standard 'name ' string + """ + names = re.split('([^<>]*)<([^<>]*)>', string) + if len(names) != 4: + raise CmdException, 'Incorrect "name " string: %s' % string + + return tuple([names[1].strip(), names[2].strip()]) diff --git a/stgit/commands/new.py b/stgit/commands/new.py index 1779d9c..c018195 100644 --- a/stgit/commands/new.py +++ b/stgit/commands/new.py @@ -29,6 +29,8 @@ usage = '%prog [options] ' options = [make_option('-m', '--message', help = 'use MESSAGE as the patch description'), + make_option('-a', '--author', metavar = '"NAME "', + help = 'use "NAME " as the author details'), make_option('--authname', help = 'use AUTHNAME as the author name'), make_option('--authemail', @@ -51,6 +53,9 @@ def func(parser, options, args): check_conflicts() check_head_top_equal() + if options.author: + options.authname, options.authemail = name_email(options.author) + crt_series.new_patch(args[0], message = options.message, author_name = options.authname, author_email = options.authemail, diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py index 81e3066..46a7ea2 100644 --- a/stgit/commands/refresh.py +++ b/stgit/commands/refresh.py @@ -39,6 +39,8 @@ options = [make_option('-f', '--force', make_option('-m', '--message', help = 'use MESSAGE as the patch ' \ 'description'), + make_option('-a', '--author', metavar = '"NAME "', + help = 'use "NAME " as the author details'), make_option('--authname', help = 'use AUTHNAME as the author name'), make_option('--authemail', @@ -71,6 +73,9 @@ def func(parser, options, args): if not options.force: check_head_top_equal() + if options.author: + options.authname, options.authemail = name_email(options.author) + if git.local_changes() \ or not crt_series.head_top_equal() \ or options.edit or options.message \ -- 2.11.0