@@ -69,7 +69,7 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
69
69
}
70
70
}
71
71
72
- let stack = stack:: working_stack (
72
+ let ( stack, stack_end_reason ) = stack:: working_stack (
73
73
repo,
74
74
config. base ,
75
75
config. force_author ,
@@ -394,14 +394,63 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
394
394
if modified_hunks_without_target > 0 {
395
395
warn ! (
396
396
logger,
397
- "Could not find a commit to fix up, use \
398
- --base to increase the search range ."
397
+ "Some file modifications did not have an available commit to fix up. \
398
+ You will have to manually create fixup commits ."
399
399
) ;
400
- }
401
400
402
- if stack. is_empty ( ) {
403
- crit ! ( logger, "No commits available to fix up, exiting" ) ;
404
- return Ok ( ( ) ) ;
401
+ match stack_end_reason {
402
+ stack:: StackEndReason :: ReachedRoot => {
403
+ warn ! (
404
+ logger,
405
+ "Cannot fix up past first commit in the repository." ;
406
+ ) ;
407
+ }
408
+ stack:: StackEndReason :: ReachedMergeCommit => {
409
+ warn ! (
410
+ logger,
411
+ "Cannot fix up past a merge commit" ;
412
+ "commit" => match stack. last( ) {
413
+ Some ( commit) => commit. 0 . id( ) . to_string( ) ,
414
+ None => head_commit. id( ) . to_string( ) ,
415
+ }
416
+ ) ;
417
+ }
418
+ stack:: StackEndReason :: ReachedAnotherAuthor => {
419
+ warn ! (
420
+ logger,
421
+ "Will not fix up past commits by another author. \
422
+ Use --force-author to override";
423
+ "commit" => match stack. last( ) {
424
+ Some ( commit) => commit. 0 . id( ) . to_string( ) ,
425
+ None => head_commit. id( ) . to_string( ) ,
426
+ }
427
+ ) ;
428
+ }
429
+ stack:: StackEndReason :: ReachedLimit => {
430
+ warn ! (
431
+ logger,
432
+ "Will not fix up past maximum stack limit. \
433
+ Use --base or configure {} to override",
434
+ config:: MAX_STACK_CONFIG_NAME ;
435
+ "limit" => config:: max_stack( repo) ,
436
+ ) ;
437
+ }
438
+ stack:: StackEndReason :: CommitsHiddenByBase => {
439
+ warn ! (
440
+ logger,
441
+ "Will not fix up past specified base commit. \
442
+ Consider using --base to specify a different base commit";
443
+ "base" => config. base. unwrap( ) ,
444
+ ) ;
445
+ }
446
+ stack:: StackEndReason :: CommitsHiddenByBranches => {
447
+ warn ! (
448
+ logger,
449
+ "Will not fix up commits reachable by other branches. \
450
+ Use --base to specify a base commit.";
451
+ ) ;
452
+ }
453
+ }
405
454
}
406
455
407
456
if config. and_rebase && !hunks_with_commit. is_empty ( ) {
@@ -637,14 +686,17 @@ mod tests {
637
686
vec ! [
638
687
& json!( {
639
688
"level" : "WARN" ,
640
- "msg" : "stack limit reached, \
641
- use --base or configure absorb.maxStack to override",
642
- "limit" : config:: MAX_STACK ,
689
+ "msg" : "Some file modifications did not have an available commit to fix up. \
690
+ You will have to manually create fixup commits.",
643
691
} ) ,
644
692
& json!( {
645
693
"level" : "WARN" ,
646
- "msg" : "Could not find a commit to fix up, \
647
- use --base to increase the search range.",
694
+ "msg" : format!(
695
+ "Will not fix up past maximum stack limit. \
696
+ Use --base or configure {} to override",
697
+ config:: MAX_STACK_CONFIG_NAME
698
+ ) ,
699
+ "limit" : config:: MAX_STACK ,
648
700
} ) ,
649
701
] ,
650
702
) ;
@@ -681,19 +733,11 @@ mod tests {
681
733
682
734
log_utils:: assert_log_messages_are (
683
735
capturing_logger. visible_logs ( ) ,
684
- vec ! [
685
- & json!( {
686
- "level" : "WARN" ,
687
- "msg" : "stack limit reached, \
688
- use --base or configure absorb.maxStack to override",
689
- "limit" : config:: MAX_STACK ,
690
- } ) ,
691
- & json!( {
692
- "level" : "WARN" ,
693
- "msg" : "No changes were in-place file modifications. \
694
- Added, removed, or renamed files cannot be automatically absorbed.",
695
- } ) ,
696
- ] ,
736
+ vec ! [ & json!( {
737
+ "level" : "WARN" ,
738
+ "msg" : "No changes were in-place file modifications. \
739
+ Added, removed, or renamed files cannot be automatically absorbed.",
740
+ } ) ] ,
697
741
) ;
698
742
}
699
743
@@ -730,19 +774,21 @@ mod tests {
730
774
vec ! [
731
775
& json!( {
732
776
"level" : "WARN" ,
733
- "msg" : "stack limit reached, \
734
- use --base or configure absorb.maxStack to override",
735
- "limit" : config:: MAX_STACK ,
777
+ "msg" : "Some changes were not in-place file modifications. \
778
+ Added, removed, or renamed files cannot be automatically absorbed.",
736
779
} ) ,
737
780
& json!( {
738
781
"level" : "WARN" ,
739
- "msg" : "Some changes were not in-place file modifications . \
740
- Added, removed, or renamed files cannot be automatically absorbed .",
782
+ "msg" : "Some file modifications did not have an available commit to fix up . \
783
+ You will have to manually create fixup commits .",
741
784
} ) ,
742
785
& json!( {
743
786
"level" : "WARN" ,
744
- "msg" : "Could not find a commit to fix up, \
745
- use --base to increase the search range.",
787
+ "msg" : format!(
788
+ "Will not fix up past maximum stack limit. \
789
+ Use --base or configure {} to override",
790
+ config:: MAX_STACK_CONFIG_NAME
791
+ ) ,
746
792
} ) ,
747
793
] ,
748
794
) ;
@@ -800,16 +846,14 @@ mod tests {
800
846
vec ! [
801
847
& json!( {
802
848
"level" : "WARN" ,
803
- "msg" : "Please try a different --base" ,
849
+ "msg" : "Some file modifications did not have an available commit to fix up. \
850
+ You will have to manually create fixup commits.",
804
851
} ) ,
805
852
& json!( {
806
853
"level" : "WARN" ,
807
- "msg" : "Could not find a commit to fix up, \
808
- use --base to increase the search range.",
809
- } ) ,
810
- & json!( {
811
- "level" : "CRIT" ,
812
- "msg" : "No commits available to fix up, exiting" ,
854
+ "msg" : "Will not fix up past specified base commit. \
855
+ Consider using --base to specify a different base commit",
856
+ "base" : "HEAD" ,
813
857
} ) ,
814
858
] ,
815
859
) ;
@@ -840,16 +884,12 @@ mod tests {
840
884
vec ! [
841
885
& json!( {
842
886
"level" : "WARN" ,
843
- "msg" : "Will not fix up past the merge commit" ,
887
+ "msg" : "Some file modifications did not have an available commit to fix up. \
888
+ You will have to manually create fixup commits.",
844
889
} ) ,
845
890
& json!( {
846
891
"level" : "WARN" ,
847
- "msg" : "Could not find a commit to fix up, \
848
- use --base to increase the search range.",
849
- } ) ,
850
- & json!( {
851
- "level" : "CRIT" ,
852
- "msg" : "No commits available to fix up, exiting" ,
892
+ "msg" : "Cannot fix up past a merge commit" ,
853
893
} ) ,
854
894
] ,
855
895
) ;
@@ -887,16 +927,10 @@ mod tests {
887
927
888
928
log_utils:: assert_log_messages_are (
889
929
capturing_logger. visible_logs ( ) ,
890
- vec ! [
891
- & json!( {
892
- "level" : "WARN" ,
893
- "msg" : "Will not fix up past the merge commit" ,
894
- } ) ,
895
- & json!( {
896
- "level" : "INFO" ,
897
- "msg" : "committed" ,
898
- } ) ,
899
- ] ,
930
+ vec ! [ & json!( {
931
+ "level" : "INFO" ,
932
+ "msg" : "committed" ,
933
+ } ) ] ,
900
934
) ;
901
935
}
902
936
@@ -928,16 +962,22 @@ mod tests {
928
962
929
963
log_utils:: assert_log_messages_are (
930
964
capturing_logger. visible_logs ( ) ,
931
- vec ! [ & json!( {
932
- "level" : "WARN" ,
933
- "msg" : "Could not find a commit to fix up, \
934
- use --base to increase the search range.",
935
- } ) ] ,
965
+ vec ! [
966
+ & json!( {
967
+ "level" : "WARN" ,
968
+ "msg" : "Some file modifications did not have an available commit to fix up. \
969
+ You will have to manually create fixup commits.",
970
+ } ) ,
971
+ & json!( {
972
+ "level" : "WARN" ,
973
+ "msg" : "Cannot fix up past a merge commit" ,
974
+ } ) ,
975
+ ] ,
936
976
) ;
937
977
}
938
978
939
979
#[ test]
940
- fn first_hidden_commit_is_foreign_author ( ) {
980
+ fn first_hidden_commit_is_by_another_author ( ) {
941
981
let ( ctx, file_path) = repo_utils:: prepare_repo ( ) ;
942
982
let first_commit = ctx. repo . head ( ) . unwrap ( ) . peel_to_commit ( ) . unwrap ( ) ;
943
983
ctx. repo
@@ -960,11 +1000,18 @@ mod tests {
960
1000
961
1001
log_utils:: assert_log_messages_are (
962
1002
capturing_logger. visible_logs ( ) ,
963
- vec ! [ & json!( {
964
- "level" : "WARN" ,
965
- "msg" : "Could not find a commit to fix up, \
966
- use --base to increase the search range.",
967
- } ) ] ,
1003
+ vec ! [
1004
+ & json!( {
1005
+ "level" : "WARN" ,
1006
+ "msg" : "Some file modifications did not have an available commit to fix up. \
1007
+ You will have to manually create fixup commits.",
1008
+ } ) ,
1009
+ & json!( {
1010
+ "level" : "WARN" ,
1011
+ "msg" : "Will not fix up past commits by another author. \
1012
+ Use --force-author to override",
1013
+ } ) ,
1014
+ ] ,
968
1015
) ;
969
1016
}
970
1017
@@ -991,11 +1038,18 @@ mod tests {
991
1038
992
1039
log_utils:: assert_log_messages_are (
993
1040
capturing_logger. visible_logs ( ) ,
994
- vec ! [ & json!( {
995
- "level" : "WARN" ,
996
- "msg" : "Could not find a commit to fix up, \
997
- use --base to increase the search range.",
998
- } ) ] ,
1041
+ vec ! [
1042
+ & json!( {
1043
+ "level" : "WARN" ,
1044
+ "msg" : "Some file modifications did not have an available commit to fix up. \
1045
+ You will have to manually create fixup commits.",
1046
+ } ) ,
1047
+ & json!( {
1048
+ "level" : "WARN" ,
1049
+ "msg" : "Will not fix up commits reachable by other branches. \
1050
+ Use --base to specify a base commit.",
1051
+ } ) ,
1052
+ ] ,
999
1053
) ;
1000
1054
}
1001
1055
@@ -1024,7 +1078,7 @@ mod tests {
1024
1078
}
1025
1079
1026
1080
#[ test]
1027
- fn foreign_author ( ) {
1081
+ fn another_author ( ) {
1028
1082
let ctx = repo_utils:: prepare_and_stage ( ) ;
1029
1083
1030
1084
repo_utils:: become_author ( & ctx. repo , "nobody2" , "nobody2@example.com" ) ;
@@ -1044,21 +1098,20 @@ mod tests {
1044
1098
vec ! [
1045
1099
& json!( {
1046
1100
"level" : "WARN" ,
1047
- "msg" : "Will not fix up past commits not authored by you, \
1048
- use --force-author to override ",
1101
+ "msg" : "Some file modifications did not have an available commit to fix up. \
1102
+ You will have to manually create fixup commits. ",
1049
1103
} ) ,
1050
1104
& json!( {
1051
1105
"level" : "WARN" ,
1052
- "msg" : "Could not find a commit to fix up, \
1053
- use --base to increase the search range." ,
1106
+ "msg" : "Will not fix up past commits by another author. \
1107
+ Use --force-author to override"
1054
1108
} ) ,
1055
- & json!( { "level" : "CRIT" , "msg" : "No commits available to fix up, exiting" } ) ,
1056
1109
] ,
1057
1110
) ;
1058
1111
}
1059
1112
1060
1113
#[ test]
1061
- fn foreign_author_with_force_author_flag ( ) {
1114
+ fn another_author_with_force_author_flag ( ) {
1062
1115
let ctx = repo_utils:: prepare_and_stage ( ) ;
1063
1116
1064
1117
repo_utils:: become_author ( & ctx. repo , "nobody2" , "nobody2@example.com" ) ;
@@ -1087,7 +1140,7 @@ mod tests {
1087
1140
}
1088
1141
1089
1142
#[ test]
1090
- fn foreign_author_with_force_author_config ( ) {
1143
+ fn another_author_with_force_author_config ( ) {
1091
1144
let ctx = repo_utils:: prepare_and_stage ( ) ;
1092
1145
1093
1146
repo_utils:: become_author ( & ctx. repo , "nobody2" , "nobody2@example.com" ) ;
@@ -1157,18 +1210,17 @@ mod tests {
1157
1210
vec ! [
1158
1211
& json!( {
1159
1212
"level" : "WARN" ,
1160
- "msg" : "HEAD is not a branch, but --force-detach used to continue." ,
1161
- } ) ,
1213
+ "msg" : "HEAD is not a branch, but --force-detach used to continue." } ) ,
1162
1214
& json!( {
1163
1215
"level" : "WARN" ,
1164
- "msg" : "Please use --base to specify a base commit." ,
1216
+ "msg" : "Some file modifications did not have an available commit to fix up. \
1217
+ You will have to manually create fixup commits.",
1165
1218
} ) ,
1166
1219
& json!( {
1167
1220
"level" : "WARN" ,
1168
- "msg" : "Could not find a commit to fix up, \
1169
- use --base to increase the search range." ,
1221
+ "msg" : "Will not fix up commits reachable by other branches. \
1222
+ Use --base to specify a base commit."
1170
1223
} ) ,
1171
- & json!( { "level" : "CRIT" , "msg" : "No commits available to fix up, exiting" } ) ,
1172
1224
] ,
1173
1225
) ;
1174
1226
}
0 commit comments