bin/gen_release_notes: Fix commits with multiple Closes:
Currently we'd only handle the last one, not all of them. Which is clearely not correct. Reviewed-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12201>
This commit is contained in:
parent
30f7b55e47
commit
da00a11bf2
|
@ -195,15 +195,13 @@ async def parse_issues(commits: str) -> typing.List[str]:
|
|||
for line in reversed(out):
|
||||
if line.startswith('Closes:'):
|
||||
bug = line.lstrip('Closes:').strip()
|
||||
break
|
||||
else:
|
||||
raise Exception('No closes found?')
|
||||
|
||||
if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'):
|
||||
# This means we have a bug in the form "Closes: https://..."
|
||||
issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
|
||||
elif bug.startswith('#'):
|
||||
issues.append(bug.lstrip('#'))
|
||||
if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'):
|
||||
# This means we have a bug in the form "Closes: https://..."
|
||||
issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
|
||||
elif ',' in bug:
|
||||
issues.extend([b.strip().lstrip('#') for b in bug.split(',')])
|
||||
elif bug.startswith('#'):
|
||||
issues.append(bug.lstrip('#'))
|
||||
|
||||
return issues
|
||||
|
||||
|
|
|
@ -117,6 +117,37 @@ async def test_gather_commits():
|
|||
''',
|
||||
[],
|
||||
),
|
||||
|
||||
# Test multiple issues on one line
|
||||
(
|
||||
'''\
|
||||
Fix many bugs
|
||||
|
||||
Closes: #1, #2
|
||||
''',
|
||||
['1', '2'],
|
||||
),
|
||||
|
||||
# Test multiple closes
|
||||
(
|
||||
'''\
|
||||
Fix many bugs
|
||||
|
||||
Closes: #1
|
||||
Closes: #2
|
||||
''',
|
||||
['1', '2'],
|
||||
),
|
||||
(
|
||||
'''\
|
||||
With long form
|
||||
|
||||
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3456
|
||||
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3457
|
||||
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3458
|
||||
''',
|
||||
['3456', '3457', '3458'],
|
||||
),
|
||||
])
|
||||
async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
|
||||
mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))
|
||||
|
@ -127,4 +158,4 @@ async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
|
|||
with mock.patch('bin.gen_release_notes.asyncio.create_subprocess_exec', mock_exec), \
|
||||
mock.patch('bin.gen_release_notes.gather_commits', mock.AsyncMock(return_value='sha\n')):
|
||||
ids = await parse_issues('1234 not used')
|
||||
assert ids == bugs
|
||||
assert set(ids) == set(bugs)
|
||||
|
|
Loading…
Reference in New Issue