summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
50dec9e)
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>
patch = __strip_patch_name(patch)
if not patch:
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('-')
else:
# fix possible invalid characters in the patch name
patch = re.sub('[^\w.]+', '-', patch).strip('-')
subject_line = msg.split('\n', 1)[0].lstrip().lower()
return re.sub('[\W]+', '-', subject_line).strip('-')[:30]
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
"""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
suffix = 0
while unacceptable('%s-%d' % (patchname, suffix)):
suffix += 1