@@ -77,11 +77,11 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
77
77
for f in files :
78
78
file_cmd = cmd + f' "{ f } "'
79
79
try :
80
- util .run (file_cmd )
80
+ util .run (file_cmd , shell = False )
81
81
except Exception as e :
82
82
# Return code 5 means no tests were run (no links found)
83
83
if e .returncode != 5 :
84
- util .run (file_cmd + " --lf" )
84
+ util .run (file_cmd + " --lf" , shell = False )
85
85
86
86
87
87
def draft_changelog (version_spec , branch , repo , since , auth , changelog_path , dry_run ):
@@ -272,8 +272,12 @@ def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
272
272
owner , repo = match ["owner" ], match ["repo" ]
273
273
gh = GhApi (owner = owner , repo = repo , token = auth )
274
274
release = util .release_for_url (gh , release_url )
275
+ branch = release .target_commitish
275
276
assets = release .assets
276
277
278
+ # Prepare a git checkout
279
+ prep_git (None , branch , f"{ owner } /{ repo } " , auth , None , None )
280
+
277
281
# Clean the dist folder
278
282
dist = Path (dist_dir )
279
283
if dist .exists ():
@@ -303,7 +307,6 @@ def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
303
307
if dry_run :
304
308
return
305
309
306
- branch = release .target_commitish
307
310
tag_name = release .tag_name
308
311
309
312
sha = None
@@ -313,17 +316,10 @@ def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
313
316
if sha is None :
314
317
raise ValueError ("Could not find tag" )
315
318
316
- # Run a git checkout
317
- # Fetch the branch
318
- # Get the commmit message for the branch
319
+ # Get the commmit message for the tag
319
320
commit_message = ""
320
- with TemporaryDirectory () as td :
321
- url = gh .repos .get ().html_url
322
- util .run (f"git clone { url } local" , cwd = td )
323
- checkout = osp .join (td , "local" )
324
- if not osp .exists (url ):
325
- util .run (f"git fetch origin { branch } " , cwd = checkout )
326
- commit_message = util .run (f"git log --format=%B -n 1 { sha } " , cwd = checkout )
321
+ checkout = osp .join (os .getcwd (), util .CHECKOUT_NAME )
322
+ commit_message = util .run (f"git log --format=%B -n 1 { sha } " , cwd = checkout )
327
323
328
324
for asset in assets :
329
325
# Check the sha against the published sha
@@ -351,13 +347,8 @@ def parse_release_url(release_url):
351
347
return match
352
348
353
349
354
- def publish_assets (dist_dir , npm_token , npm_cmd , twine_cmd , dry_run , use_checkout_dir ):
350
+ def publish_assets (dist_dir , npm_token , npm_cmd , twine_cmd , dry_run ):
355
351
"""Publish release asset(s)"""
356
- if use_checkout_dir :
357
- if not osp .exists (util .CHECKOUT_NAME ):
358
- raise ValueError ("Please run prep-git first" )
359
- os .chdir (util .CHECKOUT_NAME )
360
-
361
352
if dry_run :
362
353
# Start local pypi server with no auth, allowing overwrites,
363
354
# in a temporary directory
@@ -424,14 +415,14 @@ def publish_release(auth, release_url):
424
415
util .actions_output ("release_url" , release .html_url )
425
416
426
417
427
- def prep_git (ref , branch , repo , auth , username , url , install = True ):
418
+ def prep_git (ref , branch , repo , auth , username , url ):
428
419
"""Set up git"""
429
420
repo = repo or util .get_repo ()
430
421
431
422
user_name = ""
432
423
try :
433
424
user_name = util .run ("git config --global user.email" )
434
- except Exception as e :
425
+ except Exception :
435
426
pass
436
427
437
428
if not user_name :
@@ -498,42 +489,42 @@ def prep_git(ref, branch, repo, auth, username, url, install=True):
498
489
util .run (checkout_cmd )
499
490
500
491
# Install the package
501
- if install :
502
- # install python package in editable mode with test deps
503
- if util .SETUP_PY .exists ():
504
- util .run ('pip install -q -e ".[test]"' )
492
+ # install python package in editable mode with test deps
493
+ if util .SETUP_PY .exists ():
494
+ util .run ('pip install -q -e ".[test]"' )
505
495
506
- # prefer yarn if yarn lock exists
507
- elif util .YARN_LOCK .exists ():
508
- if not shutil .which ("yarn" ):
509
- util .run ("npm install -g yarn" )
510
- util .run ("yarn" )
496
+ # prefer yarn if yarn lock exists
497
+ elif util .YARN_LOCK .exists ():
498
+ if not shutil .which ("yarn" ):
499
+ util .run ("npm install -g yarn" )
500
+ util .run ("yarn" )
511
501
512
- # npm install otherwise
513
- elif util .PACKAGE_JSON .exists ():
514
- util .run ("npm install" )
502
+ # npm install otherwise
503
+ elif util .PACKAGE_JSON .exists ():
504
+ util .run ("npm install" )
515
505
516
506
os .chdir (orig_dir )
517
507
518
508
return branch
519
509
520
510
521
511
def forwardport_changelog (
522
- auth , ref , branch , repo , username , changelog_path , dry_run , git_url , release_url
512
+ auth , ref , branch , repo , username , changelog_path , dry_run , release_url
523
513
):
524
514
"""Forwardport Changelog Entries to the Default Branch"""
525
515
# Set up the git repo with the branch
526
516
match = parse_release_url (release_url )
527
517
gh = GhApi (owner = match ["owner" ], repo = match ["repo" ], token = auth )
528
518
release = util .release_for_url (gh , release_url )
529
519
tag = release .tag_name
520
+ source_branch = release .target_commitish
530
521
531
522
repo = f'{ match ["owner" ]} /{ match ["repo" ]} '
532
523
533
- # We want to target the main branch
534
- orig_dir = os . getcwd ()
535
- branch = prep_git ( None , None , repo , auth , username , git_url , install = False )
536
- os . chdir ( util .CHECKOUT_NAME )
524
+ # switch to main branch here
525
+ branch = branch or util . get_default_branch ()
526
+ util . run ( f"git fetch origin { branch } " )
527
+ util .run ( f"git checkout { branch } " )
537
528
538
529
# Bail if the tag has been merged to the branch
539
530
tags = util .run (f"git --no-pager tag --merged { branch } " , quiet = True )
@@ -594,5 +585,4 @@ def forwardport_changelog(
594
585
)
595
586
596
587
# Clean up after ourselves
597
- os .chdir (orig_dir )
598
- shutil .rmtree (util .CHECKOUT_NAME )
588
+ util .run (f"git checkout { source_branch } " )
0 commit comments