Read new Manager release notes from Git without unsupported subprocess arguments

This commit is contained in:
Дмитрий committed 2026-10-22 00:02:16 +05:00
1 parent 517e04dace
commit 112cb7e69c
2 files changed
+23 -3

No files matched your search

+3 -3
View File
@@ -75,14 +75,14 @@ def remote_fragments(repo, sha, seen, areas):
def collect_manager(root, tag, seen):
sha = subprocess.check_output(['git', '-C', str(root), 'rev-parse', tag + '^{commit}'], encoding='utf8', newline='\n').strip()
paths = subprocess.check_output(['git', '-C', str(root), 'ls-tree', '-r', '--name-only', sha, 'changelog.d'], encoding='utf8', newline='\n').splitlines()
sha = subprocess.check_output(['git', '-C', str(root), 'rev-parse', tag + '^{commit}'], encoding='utf8').strip()
paths = subprocess.check_output(['git', '-C', str(root), 'ls-tree', '-r', '--name-only', sha, 'changelog.d'], encoding='utf8').splitlines()
paths = [p for p in paths if re.fullmatch(r'changelog.d/\d{8}-[a-z0-9-]+\.md', p)]
repo = 'Corfirean/coa-server-manager'
notes = []
for path in paths:
if repo + ':' + Path(path).name not in seen:
text = subprocess.check_output(['git', '-C', str(root), 'show', f'{sha}:{path}'], encoding='utf8', newline='\n')
text = subprocess.check_output(['git', '-C', str(root), 'show', f'{sha}:{path}'], encoding='utf8')
note = fragment_note(text, MANAGER_AREAS)
if note:
notes.append(note)
+20
View File
@@ -51,6 +51,26 @@ class ComponentHistoryTests(unittest.TestCase):
api.assert_called_once_with('repos/owner/repo/contents/changelog.d?ref=' + 'a' * 40)
with self.assertRaises(ValueError): sync.remote_fragments('owner/repo', 'main', set(), sync.SERVER_AREAS)
def test_manager_collection_reads_the_real_frozen_tag(self):
with tempfile.TemporaryDirectory() as folder:
root = Path(folder)
fragments = root / 'changelog.d'
fragments.mkdir()
own = fragments / '20261021-own.md'
own.write_text('---\narea: manager\ntitle: Characters show their saved versions\n---\n', encoding='utf8')
(fragments / '20261021-server.md').write_text('---\narea: server\ntitle: Server only\n---\n', encoding='utf8')
subprocess.run(['git', 'init', '-q', str(root)], check=True)
subprocess.run(['git', '-C', str(root), 'add', '.'], check=True)
subprocess.run(['git', '-C', str(root), '-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.invalid', '-c', 'commit.gpgsign=false', 'commit', '-qm', 'Frozen notes'], check=True)
subprocess.run(['git', '-C', str(root), 'tag', 'v0.7.0'], check=True)
own.write_text('Uncommitted content must not become release notes', encoding='utf8')
notes, ids, source = sync.collect_manager(root, 'v0.7.0', set())
self.assertEqual(notes, ['Characters show their saved versions'])
self.assertEqual(len(ids), 2)
self.assertEqual(len(source['commit']), 40)
seen = {'Corfirean/coa-server-manager:20261021-own.md'}
self.assertEqual(sync.collect_manager(root, 'v0.7.0', seen)[0], [])
def test_render_is_component_scoped_and_stable(self):
text = sync.render(self.history())
self.assertIn('# CoA Server Manager changelog', text)