49c729d5e5c4412185c109da206deeeba15807cb
3 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 from optparse
import OptionParser
, make_option
22 from stgit
.commands
.common
import *
23 from stgit
.utils
import *
24 from stgit
import stack
, git
27 help = 'create a new patch and make it the topmost one'
28 usage
= """%prog [options] [name]
30 Create a new, empty patch and make it the topmost one. If the
31 '--message' option is not passed, an editor is invoked with the
32 .git/patchdescr.tmpl, ~/.stgit/templates/patchdescr.tmpl or
33 /usr/share/stgit/templates/patchdescr.tmpl file used a as template,
34 together with generated lines. By default, the local changes in the
35 working tree are not included in the patch. A 'refresh' command is
38 If no name is given for the new patch, one is generated from the first
39 line of the commit message."""
41 directory
= DirectoryGotoToplevel()
42 options
= [make_option('-m', '--message',
43 help = 'use MESSAGE as the patch description'),
44 make_option('-s', '--showpatch',
45 help = 'show the patch content in the editor buffer',
46 action
= 'store_true'),
47 make_option('-a', '--author', metavar
= '"NAME <EMAIL>"',
48 help = 'use "NAME <EMAIL>" as the author details'),
49 make_option('--authname',
50 help = 'use AUTHNAME as the author name'),
51 make_option('--authemail',
52 help = 'use AUTHEMAIL as the author e-mail'),
53 make_option('--authdate',
54 help = 'use AUTHDATE as the author date'),
55 make_option('--commname',
56 help = 'use COMMNAME as the committer name'),
57 make_option('--commemail',
58 help = 'use COMMEMAIL as the committer e-mail')
59 ] + make_sign_options()
62 def func(parser
, options
, args
):
63 """Creates a new patch
66 name
= None # autogenerate a name
70 parser
.error('incorrect number of arguments')
73 check_head_top_equal(crt_series
)
76 options
.authname
, options
.authemail
= name_email(options
.author
)
78 crt_series
.new_patch(name
, message
= options
.message
,
79 show_patch
= options
.showpatch
,
80 author_name
= options
.authname
,
81 author_email
= options
.authemail
,
82 author_date
= options
.authdate
,
83 committer_name
= options
.commname
,
84 committer_email
= options
.commemail
,
85 sign_str
= options
.sign_str
)