@@ -44,10 +44,7 @@ def get_git_info() -> dict:
44
44
# Get the current commit hash
45
45
try :
46
46
result = subprocess .run (
47
- ["git" , "rev-parse" , "HEAD" ],
48
- capture_output = True ,
49
- text = True ,
50
- check = True
47
+ ["git" , "rev-parse" , "HEAD" ], capture_output = True , text = True , check = True
51
48
)
52
49
info ["commit" ] = result .stdout .strip ()[:7 ] # Short hash
53
50
except Exception :
@@ -59,7 +56,7 @@ def get_git_info() -> dict:
59
56
["git" , "remote" , "get-url" , "origin" ],
60
57
capture_output = True ,
61
58
text = True ,
62
- check = True
59
+ check = True ,
63
60
)
64
61
remote_url = result .stdout .strip ()
65
62
# Extract owner/repo from URL
@@ -95,11 +92,7 @@ def get_pr_metadata() -> dict:
95
92
return metadata
96
93
97
94
98
- def format_changelog_entry (
99
- entry : dict ,
100
- config : dict ,
101
- pr_metadata : dict
102
- ) -> str :
95
+ def format_changelog_entry (entry : dict , config : dict , pr_metadata : dict ) -> str :
103
96
"""Format a single changelog entry with PR and commit info."""
104
97
description = entry ["description" ]
105
98
pr_number = pr_metadata .get ("pr_number" )
@@ -129,11 +122,7 @@ def format_changelog_entry(
129
122
130
123
131
124
def generate_changelog_section (
132
- package : str ,
133
- new_version : str ,
134
- entries : list [dict ],
135
- config : dict ,
136
- pr_metadata : dict
125
+ package : str , new_version : str , entries : list [dict ], config : dict , pr_metadata : dict
137
126
) -> str :
138
127
"""Generate changelog section for a package version."""
139
128
lines = []
@@ -159,7 +148,7 @@ def generate_changelog_section(
159
148
type_label = {
160
149
"major" : "Major Changes" ,
161
150
"minor" : "Minor Changes" ,
162
- "patch" : "Patch Changes"
151
+ "patch" : "Patch Changes" ,
163
152
}.get (change_type , f"{ change_type .capitalize ()} Changes" )
164
153
165
154
lines .append (f"### { type_label } " )
@@ -175,9 +164,7 @@ def generate_changelog_section(
175
164
176
165
177
166
def update_or_create_changelog (
178
- changelog_path : Path ,
179
- package_name : str ,
180
- new_section : str
167
+ changelog_path : Path , package_name : str , new_section : str
181
168
) -> bool :
182
169
"""Update or create a changelog file."""
183
170
if changelog_path .exists ():
@@ -264,11 +251,9 @@ def process_changesets_for_changelog() -> tuple[list[dict], str]:
264
251
if package not in package_changes :
265
252
package_changes [package ] = {"changes" : [], "descriptions" : []}
266
253
package_changes [package ]["changes" ].append (change_type )
267
- package_changes [package ]["descriptions" ].append ({
268
- "type" : change_type ,
269
- "description" : desc ,
270
- "changeset" : filepath .name
271
- })
254
+ package_changes [package ]["descriptions" ].append (
255
+ {"type" : change_type , "description" : desc , "changeset" : filepath .name }
256
+ )
272
257
273
258
# Process each package
274
259
package_updates = []
@@ -288,24 +273,22 @@ def process_changesets_for_changelog() -> tuple[list[dict], str]:
288
273
289
274
# Generate changelog content
290
275
changelog_content = generate_changelog_section (
291
- package ,
292
- new_version ,
293
- info ["descriptions" ],
294
- config ,
295
- pr_metadata
276
+ package , new_version , info ["descriptions" ], config , pr_metadata
296
277
)
297
278
298
279
# Find changelog path (same directory as pyproject.toml)
299
280
changelog_path = pyproject_path .parent / "CHANGELOG.md"
300
281
301
- package_updates .append ({
302
- "package" : package ,
303
- "version" : new_version ,
304
- "current_version" : current_version ,
305
- "changelog_path" : changelog_path ,
306
- "changelog_content" : changelog_content ,
307
- "pyproject_path" : pyproject_path ,
308
- })
282
+ package_updates .append (
283
+ {
284
+ "package" : package ,
285
+ "version" : new_version ,
286
+ "current_version" : current_version ,
287
+ "changelog_path" : changelog_path ,
288
+ "changelog_content" : changelog_content ,
289
+ "pyproject_path" : pyproject_path ,
290
+ }
291
+ )
309
292
310
293
# Generate PR description
311
294
pr_description = generate_pr_description (package_updates )
@@ -335,35 +318,33 @@ def main(dry_run: bool, output_pr_description: str):
335
318
click .style (f"Found updates for { len (package_updates )} package(s):" , fg = "green" )
336
319
)
337
320
for update in package_updates :
338
- current = update [' current_version' ]
339
- new = update [' version' ]
321
+ current = update [" current_version" ]
322
+ new = update [" version" ]
340
323
click .echo (f" 📦 { update ['package' ]} : { current } → { new } " )
341
324
342
325
if dry_run :
343
326
click .echo (
344
327
click .style ("\n 🔍 Dry run mode - no changes will be made" , fg = "yellow" )
345
328
)
346
- click .echo ("\n " + "=" * 60 )
329
+ click .echo ("\n " + "=" * 60 )
347
330
click .echo (click .style ("PR Description:" , fg = "cyan" ))
348
- click .echo ("=" * 60 )
331
+ click .echo ("=" * 60 )
349
332
click .echo (pr_description )
350
- click .echo ("=" * 60 )
333
+ click .echo ("=" * 60 )
351
334
352
335
for update in package_updates :
353
336
click .echo (
354
337
click .style (f"\n Changelog for { update ['changelog_path' ]} :" , fg = "cyan" )
355
338
)
356
- click .echo ("-" * 60 )
339
+ click .echo ("-" * 60 )
357
340
click .echo (update ["changelog_content" ])
358
- click .echo ("-" * 60 )
341
+ click .echo ("-" * 60 )
359
342
return
360
343
361
344
# Update changelog files
362
345
for update in package_updates :
363
346
success = update_or_create_changelog (
364
- update ["changelog_path" ],
365
- update ["package" ],
366
- update ["changelog_content" ]
347
+ update ["changelog_path" ], update ["package" ], update ["changelog_content" ]
367
348
)
368
349
369
350
if success :
0 commit comments