@@ -210,9 +210,7 @@ def commit_id(self) -> str:
210
210
return self ._search_group (RE_RAW_COMMIT_ID , "commit" )
211
211
212
212
def parents (self ) -> List [str ]:
213
- return [
214
- m .group ("commit" ) for m in RE_RAW_PARENT .finditer (self .raw_header )
215
- ]
213
+ return [m .group ("commit" ) for m in RE_RAW_PARENT .finditer (self .raw_header )]
216
214
217
215
def author (self ) -> str :
218
216
return self ._search_group (RE_RAW_AUTHOR , "author" )
@@ -225,8 +223,7 @@ def author_email(self) -> str:
225
223
226
224
def commit_msg (self ) -> str :
227
225
return "\n " .join (
228
- m .group ("line" )
229
- for m in RE_RAW_COMMIT_MSG_LINE .finditer (self .raw_header )
226
+ m .group ("line" ) for m in RE_RAW_COMMIT_MSG_LINE .finditer (self .raw_header )
230
227
)
231
228
232
229
@@ -437,9 +434,7 @@ def get_stack(base: str, head: str, verbose: bool) -> List[StackEntry]:
437
434
st : List [StackEntry ] = []
438
435
stack = (
439
436
split_header (
440
- get_command_output (
441
- ["git" , "rev-list" , "--header" , "^" + base , head ]
442
- )
437
+ get_command_output (["git" , "rev-list" , "--header" , "^" + base , head ])
443
438
)
444
439
)[::- 1 ]
445
440
@@ -506,7 +501,11 @@ def verify(st: List[StackEntry], check_base: bool = False):
506
501
raise RuntimeError
507
502
508
503
# The first entry on the stack needs to be actually mergeable on GitHub.
509
- if check_base and index == 0 and d ["mergeStateStatus" ] not in ["CLEAN" , "UNKNOWN" , "UNSTABLE" ]:
504
+ if (
505
+ check_base
506
+ and index == 0
507
+ and d ["mergeStateStatus" ] not in ["CLEAN" , "UNKNOWN" , "UNSTABLE" ]
508
+ ):
510
509
error (ERROR_STACKINFO_PR_NOT_MERGEABLE .format (** locals ()))
511
510
raise RuntimeError
512
511
@@ -529,9 +528,7 @@ def draft_bitmask_type(value: str) -> List[bool]:
529
528
# ===----------------------------------------------------------------------=== #
530
529
# SUBMIT
531
530
# ===----------------------------------------------------------------------=== #
532
- def add_or_update_metadata (
533
- e : StackEntry , needs_rebase : bool , verbose : bool
534
- ) -> bool :
531
+ def add_or_update_metadata (e : StackEntry , needs_rebase : bool , verbose : bool ) -> bool :
535
532
if needs_rebase :
536
533
run_shell_command (
537
534
[
@@ -631,14 +628,14 @@ def push_branches(st: List[StackEntry], remote, verbose: bool):
631
628
632
629
def print_cmd_failure_details (exc : SubprocessError ):
633
630
cmd_stdout = (
634
- exc .stdout .decode ("utf-8" )
635
- . replace ( " \\ n" , " \n " )
636
- . replace ( " \\ t" , " \t " ) if exc . stdout else None
631
+ exc .stdout .decode ("utf-8" ). replace ( " \\ n" , " \n " ). replace ( " \\ t" , " \t " )
632
+ if exc . stdout
633
+ else None
637
634
)
638
635
cmd_stderr = (
639
- exc .stderr .decode ("utf-8" )
640
- . replace ( " \\ n" , " \n " )
641
- . replace ( " \\ t" , " \t " ) if exc . stderr else None
636
+ exc .stderr .decode ("utf-8" ). replace ( " \\ n" , " \n " ). replace ( " \\ t" , " \t " )
637
+ if exc . stderr
638
+ else None
642
639
)
643
640
print (f"Exitcode: { exc .returncode } " )
644
641
print (f"Stdout: { cmd_stdout } " )
@@ -716,9 +713,7 @@ def add_cross_links(st: List[StackEntry], keep_body: bool, verbose: bool):
716
713
if keep_body :
717
714
# Keep current body of the PR after the cross links component
718
715
current_pr_body = get_current_pr_body (e )
719
- pr_body .append (
720
- current_pr_body .split (CROSS_LINKS_DELIMETER , 1 )[- 1 ].lstrip ()
721
- )
716
+ pr_body .append (current_pr_body .split (CROSS_LINKS_DELIMETER , 1 )[- 1 ].lstrip ())
722
717
else :
723
718
pr_body .extend (
724
719
[
@@ -758,15 +753,11 @@ def add_cross_links(st: List[StackEntry], keep_body: bool, verbose: bool):
758
753
#
759
754
# To avoid this, we temporarily set all base branches to point to 'main' - once
760
755
# all the branches are pushed we can set the actual base branches.
761
- def reset_remote_base_branches (
762
- st : List [StackEntry ], target : str , verbose : bool
763
- ):
756
+ def reset_remote_base_branches (st : List [StackEntry ], target : str , verbose : bool ):
764
757
log (h ("Resetting remote base branches" ), level = 1 )
765
758
766
759
for e in filter (lambda e : e .has_pr (), st ):
767
- run_shell_command (
768
- ["gh" , "pr" , "edit" , e .pr , "-B" , target ], quiet = not verbose
769
- )
760
+ run_shell_command (["gh" , "pr" , "edit" , e .pr , "-B" , target ], quiet = not verbose )
770
761
771
762
772
763
# If local 'main' lags behind 'origin/main', and 'head' contains all commits
@@ -794,9 +785,7 @@ def should_update_local_base(
794
785
795
786
def update_local_base (base : str , remote : str , target : str , verbose : bool ):
796
787
log (h (f"Updating local branch { base } to { remote } /{ target } " ), level = 1 )
797
- run_shell_command (
798
- ["git" , "rebase" , f"{ remote } /{ target } " , base ], quiet = not verbose
799
- )
788
+ run_shell_command (["git" , "rebase" , f"{ remote } /{ target } " , base ], quiet = not verbose )
800
789
801
790
802
791
class CommonArgs (NamedTuple ):
@@ -882,9 +871,7 @@ def command_submit(
882
871
args .head , args .base , args .remote , args .target , args .verbose
883
872
):
884
873
update_local_base (args .base , args .remote , args .target , args .verbose )
885
- run_shell_command (
886
- ["git" , "checkout" , current_branch ], quiet = not args .verbose
887
- )
874
+ run_shell_command (["git" , "checkout" , current_branch ], quiet = not args .verbose )
888
875
889
876
# Determine what commits belong to the stack
890
877
st = get_stack (args .base , args .head , args .verbose )
@@ -902,18 +889,14 @@ def command_submit(
902
889
903
890
# Create local branches and initialize base and head fields in the stack
904
891
# elements
905
- init_local_branches (
906
- st , args .remote , args .verbose , args .branch_name_template
907
- )
892
+ init_local_branches (st , args .remote , args .verbose , args .branch_name_template )
908
893
set_base_branches (st , args .target )
909
894
print_stack (st , args .hyperlinks )
910
895
911
896
# If the current branch contains commits from the stack, we will need to
912
897
# rebase it in the end since the commits will be modified.
913
898
top_branch = st [- 1 ].head
914
- need_to_rebase_current = is_ancestor (
915
- top_branch , current_branch , args .verbose
916
- )
899
+ need_to_rebase_current = is_ancestor (top_branch , current_branch , args .verbose )
917
900
918
901
reset_remote_base_branches (st , args .target , args .verbose )
919
902
@@ -923,9 +906,7 @@ def command_submit(
923
906
# Now we have all the branches, so we can create the corresponding PRs
924
907
log (h ("Submitting PRs" ), level = 1 )
925
908
for e_idx , e in enumerate (st ):
926
- is_pr_draft = draft or (
927
- (draft_bitmask is not None ) and draft_bitmask [e_idx ]
928
- )
909
+ is_pr_draft = draft or ((draft_bitmask is not None ) and draft_bitmask [e_idx ])
929
910
create_pr (e , is_pr_draft , reviewer )
930
911
931
912
# Verify consistency in everything we have so far
@@ -960,9 +941,7 @@ def command_submit(
960
941
)
961
942
else :
962
943
log (h (f"Checking out the original branch '{ current_branch } '" ), level = 1 )
963
- run_shell_command (
964
- ["git" , "checkout" , current_branch ], quiet = not args .verbose
965
- )
944
+ run_shell_command (["git" , "checkout" , current_branch ], quiet = not args .verbose )
966
945
967
946
delete_local_branches (st , args .verbose )
968
947
print_tips_after_export (st , args )
@@ -1012,9 +991,7 @@ def land_pr(e: StackEntry, remote: str, target: str, verbose: bool):
1012
991
raise
1013
992
1014
993
# Switch PR base branch to 'main'
1015
- run_shell_command (
1016
- ["gh" , "pr" , "edit" , e .pr , "-B" , target ], quiet = not verbose
1017
- )
994
+ run_shell_command (["gh" , "pr" , "edit" , e .pr , "-B" , target ], quiet = not verbose )
1018
995
1019
996
# Form the commit message: it should contain the original commit message
1020
997
# and nothing else.
@@ -1077,9 +1054,7 @@ def command_land(args: CommonArgs):
1077
1054
args .head , args .base , args .remote , args .target , args .verbose
1078
1055
):
1079
1056
update_local_base (args .base , args .remote , args .target , args .verbose )
1080
- run_shell_command (
1081
- ["git" , "checkout" , current_branch ], quiet = not args .verbose
1082
- )
1057
+ run_shell_command (["git" , "checkout" , current_branch ], quiet = not args .verbose )
1083
1058
1084
1059
# Determine what commits belong to the stack
1085
1060
st = get_stack (args .base , args .head , args .verbose )
@@ -1114,9 +1089,7 @@ def command_land(args: CommonArgs):
1114
1089
)
1115
1090
1116
1091
# Delete local and remote stack branches
1117
- run_shell_command (
1118
- ["git" , "checkout" , current_branch ], quiet = not args .verbose
1119
- )
1092
+ run_shell_command (["git" , "checkout" , current_branch ], quiet = not args .verbose )
1120
1093
1121
1094
delete_local_branches (st , args .verbose )
1122
1095
@@ -1166,9 +1139,7 @@ def command_abandon(args: CommonArgs):
1166
1139
return
1167
1140
current_branch = get_current_branch_name ()
1168
1141
1169
- init_local_branches (
1170
- st , args .remote , args .verbose , args .branch_name_template
1171
- )
1142
+ init_local_branches (st , args .remote , args .verbose , args .branch_name_template )
1172
1143
set_base_branches (st , args .target )
1173
1144
print_stack (st , args .hyperlinks )
1174
1145
@@ -1184,9 +1155,7 @@ def command_abandon(args: CommonArgs):
1184
1155
)
1185
1156
1186
1157
delete_local_branches (st , args .verbose )
1187
- delete_remote_branches (
1188
- st , args .remote , args .verbose , args .branch_name_template
1189
- )
1158
+ delete_remote_branches (st , args .remote , args .verbose , args .branch_name_template )
1190
1159
log (h (blue ("SUCCESS!" )), level = 1 )
1191
1160
1192
1161
@@ -1235,10 +1204,7 @@ def command_view(args: CommonArgs):
1235
1204
level = 1 ,
1236
1205
)
1237
1206
log (
1238
- (
1239
- "Consider updating your local branch by"
1240
- " running the following commands:"
1241
- ),
1207
+ ("Consider updating your local branch by running the following commands:" ),
1242
1208
level = 1 ,
1243
1209
)
1244
1210
log (
@@ -1279,9 +1245,7 @@ def create_argparser(
1279
1245
help = "Remote name" ,
1280
1246
)
1281
1247
common_parser .add_argument ("-B" , "--base" , help = "Local base branch" )
1282
- common_parser .add_argument (
1283
- "-H" , "--head" , default = "HEAD" , help = "Local head branch"
1284
- )
1248
+ common_parser .add_argument ("-H" , "--head" , default = "HEAD" , help = "Local head branch" )
1285
1249
common_parser .add_argument (
1286
1250
"-T" ,
1287
1251
"--target" ,
@@ -1303,9 +1267,7 @@ def create_argparser(
1303
1267
)
1304
1268
common_parser .add_argument (
1305
1269
"--branch-name-template" ,
1306
- default = config .get (
1307
- "repo" , "branch_name_template" , fallback = "$USERNAME/stack"
1308
- ),
1270
+ default = config .get ("repo" , "branch_name_template" , fallback = "$USERNAME/stack" ),
1309
1271
help = "A template for names of the branches stack-pr would use." ,
1310
1272
)
1311
1273
0 commit comments