From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, Petr Baudis <pasky@suse.cz>
Subject: [StGIT PATCH 3/5] Remove an unnecessary parameter to make_patch_name
Date: Fri, 11 May 2007 03:40:16 +0200 [thread overview]
Message-ID: <20070511014016.13161.33634.stgit@yoghurt> (raw)
In-Reply-To: <20070511013400.13161.9160.stgit@yoghurt>
From: Karl Hasselström <kha@treskal.com>
The "alternative" parameter was a boolean that indicated whether we
were interested in testing if the first generated name was acceptable,
or if we would just always accept it. But that can be accomplished by
giving an "unacceptable" function that always returns False, so
there's no need for an additional parameter.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/imprt.py | 8 +++++---
stgit/utils.py | 5 ++---
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 89af472..6fcdc62 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -242,9 +242,11 @@ def __create_patch(filename, message, author_name, author_email,
patch = __strip_patch_name(patch)
if not patch:
- patch = make_patch_name(message, crt_series.patch_exists,
- alternative = not (options.ignore
- or options.replace))
+ if options.ignore or options.replace:
+ unacceptable_name = lambda name: False
+ else:
+ unacceptable_name = crt_series.patch_exists
+ patch = make_patch_name(message, unacceptable_name)
else:
# fix possible invalid characters in the patch name
patch = re.sub('[^\w.]+', '-', patch).strip('-')
diff --git a/stgit/utils.py b/stgit/utils.py
index 3612a4b..fbfe748 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -183,15 +183,14 @@ def patch_name_from_msg(msg):
subject_line = msg.split('\n', 1)[0].lstrip().lower()
return re.sub('[\W]+', '-', subject_line).strip('-')[:30]
-def make_patch_name(msg, unacceptable, default_name = 'patch',
- alternative = True):
+def make_patch_name(msg, unacceptable, default_name = 'patch'):
"""Return a patch name generated from the given commit message,
guaranteed to make unacceptable(name) be false. If the commit
message is empty, base the name on default_name instead."""
patchname = patch_name_from_msg(msg)
if not patchname:
patchname = default_name
- if alternative and unacceptable(patchname):
+ if unacceptable(patchname):
suffix = 0
while unacceptable('%s-%d' % (patchname, suffix)):
suffix += 1
next prev parent reply other threads:[~2007-05-11 1:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-11 1:39 [StGIT PATCH 0/5] Some tweaks and enhancements Karl Hasselström
2007-05-11 1:40 ` [StGIT PATCH 1/5] Make the "name" argument to "stg new" optional Karl Hasselström
2007-05-11 1:40 ` [StGIT PATCH 2/5] Generate patch names of more uniform length Karl Hasselström
2007-05-11 1:40 ` Karl Hasselström [this message]
2007-05-11 1:40 ` [StGIT PATCH 4/5] If any uncommit would fail, don't uncommit anything Karl Hasselström
2007-05-11 1:40 ` [StGIT PATCH 5/5] Uncommit to a named commit 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=20070511014016.13161.33634.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/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).