Allow tags prefixed with v in default regex
The version scheme v1.0.0 is not an uncommon way to tag versions and used to be part of the semver spec. This patch allows the optional v prefix in the default version scheme. ref: https://github.com/semver/semver/blob/master/semver.md#is-v123-a-semantic-version Change-Id: I4a99bda8b788ee5fd2a8aca3463eb548d07f1313 Signed-off-by: Thanh Ha <zxiiro@linux.com>
This commit is contained in:
parent
f7bf78209b
commit
9b1c353bd0
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Allow optional 'v' prefix in the default version tag regex.
|
|
@ -66,7 +66,7 @@ _OPTIONS = [
|
|||
|
||||
Opt('release_tag_re',
|
||||
textwrap.dedent('''\
|
||||
((?:[\d.ab]|rc)+) # digits, a, b, and rc cover regular and
|
||||
((?:v?[\d.ab]|rc)+) # digits, a, b, and rc cover regular and
|
||||
# pre-releases
|
||||
'''),
|
||||
textwrap.dedent("""\
|
||||
|
@ -77,7 +77,7 @@ _OPTIONS = [
|
|||
|
||||
Opt('pre_release_tag_re',
|
||||
textwrap.dedent('''\
|
||||
(?P<pre_release>\.\d+(?:[ab]|rc)+\d*)$
|
||||
(?P<pre_release>\.v?\d+(?:[ab]|rc)+\d*)$
|
||||
'''),
|
||||
textwrap.dedent("""\
|
||||
The regex pattern used to check if a valid release version tag
|
||||
|
|
|
@ -273,6 +273,20 @@ class BasicTest(Base):
|
|||
results,
|
||||
)
|
||||
|
||||
def test_tag_with_v_prefix(self):
|
||||
filename = self._add_notes_file()
|
||||
self.repo.git('tag', '-s', '-m', 'tag with v prefix', 'v1.0.0')
|
||||
self.scanner = scanner.Scanner(self.c)
|
||||
raw_results = self.scanner.get_notes_by_version()
|
||||
results = {
|
||||
k: [f for (f, n) in v]
|
||||
for (k, v) in raw_results.items()
|
||||
}
|
||||
self.assertEqual(
|
||||
{'v1.0.0': [filename]},
|
||||
results,
|
||||
)
|
||||
|
||||
def test_note_commit_after_tag(self):
|
||||
self._make_python_package()
|
||||
self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
|
||||
|
@ -876,6 +890,23 @@ class PreReleaseTest(Base):
|
|||
results,
|
||||
)
|
||||
|
||||
def test_tag_with_v_prefix(self):
|
||||
self._make_python_package()
|
||||
self.repo.git('tag', '-s', '-m', 'first tag', 'v1.0.0.0a1')
|
||||
f1 = self._add_notes_file('slug1')
|
||||
self.repo.git('tag', '-s', '-m', 'first tag', 'v1.0.0.0a2')
|
||||
self.scanner = scanner.Scanner(self.c)
|
||||
raw_results = self.scanner.get_notes_by_version()
|
||||
results = {
|
||||
k: [f for (f, n) in v]
|
||||
for (k, v) in raw_results.items()
|
||||
}
|
||||
self.assertEqual(
|
||||
{'v1.0.0.0a2': [f1],
|
||||
},
|
||||
results,
|
||||
)
|
||||
|
||||
def test_collapse(self):
|
||||
files = []
|
||||
self._make_python_package()
|
||||
|
|
Loading…
Reference in New Issue