Synchronize the changelog in the PR body based on the changed files.
Parameters
provider
The GitProvider instance to interact with the git provider.
pr_number
The pull request number to synchronize the changelog for.
Source code in taglyatelle/background_commands/synchronize_changelog.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 | def synchronize_changelog(provider: GitProvider, pr_number: int) -> None:
"""
Synchronize the changelog in the PR body based on the changed files.
Parameters
----------
provider
The GitProvider instance to interact with the git provider.
pr_number
The pull request number to synchronize the changelog for.
"""
pr_files = provider.get_pr_files(pr_number)
files_summary = []
for file_info in pr_files:
filename = file_info.get("filename", "")
status = file_info.get("status", "")
additions = file_info.get("additions", 0)
deletions = file_info.get("deletions", 0)
patch = file_info.get("patch", "")
files_summary.append(f"""
File: {filename}
Status: {status}
Changes: +{additions} -{deletions}
Patch:{patch}""")
changelog_prompt = f"""
Based on the following pull request changes, generate a changelog description in this format:
## Added
[List new features, functionality, or files that were added]
## Modified
[List existing features, functionality, or files that were changed/updated]
## Fixed
[List bugs, issues, or problems that were resolved]
Pull Request Files Changed:
{"".join(files_summary)}
Instructions:
- Analyze the code changes and categorize them appropriately
- Use bullet points with clear, concise descriptions
- Focus on user-facing changes and important technical improvements
- If a category has no changes, omit it.
- Keep descriptions professional and informative without too much verbosity.
- Return ONLY the changelog content in plain text without markdown code blocks or backticks.
"""
changelog = provider.invoke_llm(changelog_prompt)
provider.create_pr_body(pr_number=pr_number, body=str(changelog))
logger.info(f"Changelog synchronized for PR #{pr_number}:\n{changelog}")
|