@@ -15,7 +15,7 @@ use crate::core::formatting::Pluralize;
15
15
use crate :: core:: repo_ext:: RepoExt ;
16
16
use crate :: git:: {
17
17
BranchType , CategorizedReferenceName , GitRunInfo , MaybeZeroOid , NonZeroOid , ReferenceName ,
18
- Repo , ResolvedReferenceInfo ,
18
+ Repo , ResolvedReferenceInfo , SignOption ,
19
19
} ;
20
20
use crate :: util:: { ExitCode , EyreExitOr } ;
21
21
@@ -435,7 +435,8 @@ mod in_memory {
435
435
use crate :: core:: rewrite:: move_branches;
436
436
use crate :: core:: rewrite:: plan:: { OidOrLabel , RebaseCommand , RebasePlan } ;
437
437
use crate :: git:: {
438
- CherryPickFastError , CherryPickFastOptions , GitRunInfo , MaybeZeroOid , NonZeroOid , Repo ,
438
+ self , CherryPickFastError , CherryPickFastOptions , GitRunInfo , MaybeZeroOid , NonZeroOid ,
439
+ Repo ,
439
440
} ;
440
441
use crate :: util:: EyreExitOr ;
441
442
@@ -498,6 +499,7 @@ mod in_memory {
498
499
force_on_disk : _,
499
500
resolve_merge_conflicts : _, // May be needed once we can resolve merge conflicts in memory.
500
501
check_out_commit_options : _, // Caller is responsible for checking out to new HEAD.
502
+ sign_option,
501
503
} = options;
502
504
503
505
let mut current_oid = rebase_plan. first_dest_oid ;
@@ -535,6 +537,8 @@ mod in_memory {
535
537
. count ( ) ;
536
538
let ( effects, progress) = effects. start_operation ( OperationType :: RebaseCommits ) ;
537
539
540
+ let signer = git:: get_signer ( & repo, sign_option) ?;
541
+
538
542
for command in rebase_plan. commands . iter ( ) {
539
543
match command {
540
544
RebaseCommand :: CreateLabel { label_name } => {
@@ -633,7 +637,7 @@ mod in_memory {
633
637
commit_message,
634
638
& commit_tree,
635
639
vec ! [ & current_commit] ,
636
- None ,
640
+ signer . as_deref ( ) ,
637
641
)
638
642
. wrap_err ( "Applying rebased commit" ) ?;
639
643
@@ -753,7 +757,7 @@ mod in_memory {
753
757
replacement_commit_message,
754
758
& replacement_tree,
755
759
parents. iter ( ) . collect ( ) ,
756
- None ,
760
+ signer . as_deref ( ) ,
757
761
)
758
762
. wrap_err ( "Applying rebased commit" ) ?;
759
763
@@ -864,6 +868,7 @@ mod in_memory {
864
868
force_on_disk : _,
865
869
resolve_merge_conflicts : _,
866
870
check_out_commit_options,
871
+ sign_option : _,
867
872
} = options;
868
873
869
874
// Note that if an OID has been mapped to multiple other OIDs, then the last
@@ -959,6 +964,7 @@ mod on_disk {
959
964
force_on_disk : _,
960
965
resolve_merge_conflicts : _,
961
966
check_out_commit_options : _, // Checkout happens after rebase has concluded.
967
+ sign_option,
962
968
} = options;
963
969
964
970
let ( effects, _progress) = effects. start_operation ( OperationType :: InitializeRebase ) ;
@@ -1073,6 +1079,16 @@ mod on_disk {
1073
1079
)
1074
1080
} ) ?;
1075
1081
1082
+ let gpg_sign_opt_file = rebase_state_dir. join ( "gpg_sign_opt" ) ;
1083
+ if let Some ( sign_flag) = sign_option. as_rebase_flag ( repo) ? {
1084
+ std:: fs:: write ( & gpg_sign_opt_file, sign_flag) . wrap_err_with ( || {
1085
+ format ! (
1086
+ "Writing `gpg_sign_opt` to: {:?}" ,
1087
+ gpg_sign_opt_file. as_path( )
1088
+ )
1089
+ } ) ?;
1090
+ }
1091
+
1076
1092
let end_file_path = rebase_state_dir. join ( "end" ) ;
1077
1093
std:: fs:: write (
1078
1094
end_file_path. as_path ( ) ,
@@ -1132,6 +1148,7 @@ mod on_disk {
1132
1148
force_on_disk : _,
1133
1149
resolve_merge_conflicts : _,
1134
1150
check_out_commit_options : _, // Checkout happens after rebase has concluded.
1151
+ sign_option : _,
1135
1152
} = options;
1136
1153
1137
1154
match write_rebase_state_to_disk ( effects, git_run_info, repo, rebase_plan, options) ? {
@@ -1176,6 +1193,9 @@ pub struct ExecuteRebasePlanOptions {
1176
1193
1177
1194
/// If `HEAD` was moved, the options for checking out the new `HEAD` commit.
1178
1195
pub check_out_commit_options : CheckOutCommitOptions ,
1196
+
1197
+ /// GPG-sign commits.
1198
+ pub sign_option : SignOption ,
1179
1199
}
1180
1200
1181
1201
/// The result of executing a rebase plan.
@@ -1221,6 +1241,7 @@ pub fn execute_rebase_plan(
1221
1241
force_on_disk,
1222
1242
resolve_merge_conflicts,
1223
1243
check_out_commit_options : _,
1244
+ sign_option : _,
1224
1245
} = options;
1225
1246
1226
1247
if !force_on_disk {
0 commit comments