diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py index 77af98ce..97bffe1b 100644 --- a/stgit/lib/stack.py +++ b/stgit/lib/stack.py @@ -205,7 +205,7 @@ def make_name(self, raw, unique=True, lower=True, allow=(), disallow=()): name_len = config.getint('stgit.namelength') - words = long_name.split('-') + words = [word.rstrip('.') for word in long_name.split('-')] short_name = words[0] for word in words[1:]: new_name = '%s-%s' % (short_name, word) @@ -213,9 +213,6 @@ def make_name(self, raw, unique=True, lower=True, allow=(), disallow=()): short_name = new_name else: break - # Strip trailing dots again because the truncation may have - # left a trailing dot, which is not allowed - short_name = re.sub(r'\.+$', '', short_name) assert self.is_name_valid(short_name) if not unique: diff --git a/t/t1003-new.sh b/t/t1003-new.sh index caff55c7..d8bae5fd 100755 --- a/t/t1003-new.sh +++ b/t/t1003-new.sh @@ -42,6 +42,14 @@ test_expect_success \ grep -e "Invalid patch name: \"\"" ' +test_expect_success \ + 'Invalid patch name: trailing periods in shortened name' ' + test_config stgit.namelength 10 && + stg new -m "aaa. bbb. ccc." && + test "$(echo $(stg top))" = "aaa-bbb" && + stg delete --top +' + test_expect_success \ 'Create a patch without giving a name' ' stg new -m yo &&