@@ -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
@@ -436,8 +436,8 @@ mod in_memory {
436
436
use crate :: core:: rewrite:: move_branches;
437
437
use crate :: core:: rewrite:: plan:: { OidOrLabel , RebaseCommand , RebasePlan } ;
438
438
use crate :: git:: {
439
- AmendFastOptions , CherryPickFastOptions , CreateCommitFastError , GitRunInfo , MaybeZeroOid ,
440
- NonZeroOid , Repo ,
439
+ self , AmendFastOptions , CherryPickFastOptions , CreateCommitFastError , GitRunInfo ,
440
+ MaybeZeroOid , NonZeroOid , Repo ,
441
441
} ;
442
442
use crate :: util:: EyreExitOr ;
443
443
@@ -500,6 +500,7 @@ mod in_memory {
500
500
force_on_disk : _,
501
501
resolve_merge_conflicts : _, // May be needed once we can resolve merge conflicts in memory.
502
502
check_out_commit_options : _, // Caller is responsible for checking out to new HEAD.
503
+ sign_option,
503
504
} = options;
504
505
505
506
let mut current_oid = rebase_plan. first_dest_oid ;
@@ -537,6 +538,8 @@ mod in_memory {
537
538
. count ( ) ;
538
539
let ( effects, progress) = effects. start_operation ( OperationType :: RebaseCommits ) ;
539
540
541
+ let signer = git:: get_signer ( repo, sign_option) ?;
542
+
540
543
for command in rebase_plan. commands . iter ( ) {
541
544
match command {
542
545
RebaseCommand :: CreateLabel { label_name } => {
@@ -670,12 +673,12 @@ mod in_memory {
670
673
) ;
671
674
rebased_commit_oid = Some (
672
675
repo. create_commit (
673
- None ,
674
676
& commit_author,
675
677
& committer_signature,
676
678
commit_message,
677
679
& commit_tree,
678
680
vec ! [ & current_commit] ,
681
+ signer. as_deref ( ) ,
679
682
)
680
683
. wrap_err ( "Applying rebased commit" ) ?,
681
684
) ;
@@ -802,12 +805,12 @@ mod in_memory {
802
805
} ;
803
806
let rebased_commit_oid = repo
804
807
. create_commit (
805
- None ,
806
808
& replacement_commit. get_author ( ) ,
807
809
& committer_signature,
808
810
replacement_commit_message,
809
811
& replacement_tree,
810
812
parents. iter ( ) . collect ( ) ,
813
+ signer. as_deref ( ) ,
811
814
)
812
815
. wrap_err ( "Applying rebased commit" ) ?;
813
816
@@ -911,6 +914,7 @@ mod in_memory {
911
914
force_on_disk : _,
912
915
resolve_merge_conflicts : _,
913
916
check_out_commit_options,
917
+ sign_option : _,
914
918
} = options;
915
919
916
920
for new_oid in rewritten_oids. values ( ) {
@@ -996,6 +1000,7 @@ mod on_disk {
996
1000
force_on_disk : _,
997
1001
resolve_merge_conflicts : _,
998
1002
check_out_commit_options : _, // Checkout happens after rebase has concluded.
1003
+ sign_option,
999
1004
} = options;
1000
1005
1001
1006
let ( effects, _progress) = effects. start_operation ( OperationType :: InitializeRebase ) ;
@@ -1113,6 +1118,16 @@ mod on_disk {
1113
1118
)
1114
1119
} ) ?;
1115
1120
1121
+ let gpg_sign_opt_path = rebase_state_dir. join ( "gpg_sign_opt" ) ;
1122
+ if let Some ( sign_flag) = sign_option. as_rebase_flag ( repo) ? {
1123
+ std:: fs:: write ( & gpg_sign_opt_path, sign_flag) . wrap_err_with ( || {
1124
+ format ! (
1125
+ "Writing `gpg_sign_opt` to: {:?}" ,
1126
+ gpg_sign_opt_path. as_path( )
1127
+ )
1128
+ } ) ?;
1129
+ }
1130
+
1116
1131
let end_file_path = rebase_state_dir. join ( "end" ) ;
1117
1132
std:: fs:: write (
1118
1133
end_file_path. as_path ( ) ,
@@ -1172,6 +1187,7 @@ mod on_disk {
1172
1187
force_on_disk : _,
1173
1188
resolve_merge_conflicts : _,
1174
1189
check_out_commit_options : _, // Checkout happens after rebase has concluded.
1190
+ sign_option : _,
1175
1191
} = options;
1176
1192
1177
1193
match write_rebase_state_to_disk ( effects, git_run_info, repo, rebase_plan, options) ? {
@@ -1216,6 +1232,9 @@ pub struct ExecuteRebasePlanOptions {
1216
1232
1217
1233
/// If `HEAD` was moved, the options for checking out the new `HEAD` commit.
1218
1234
pub check_out_commit_options : CheckOutCommitOptions ,
1235
+
1236
+ /// GPG-sign commits.
1237
+ pub sign_option : SignOption ,
1219
1238
}
1220
1239
1221
1240
/// The result of executing a rebase plan.
@@ -1261,6 +1280,7 @@ pub fn execute_rebase_plan(
1261
1280
force_on_disk,
1262
1281
resolve_merge_conflicts,
1263
1282
check_out_commit_options : _,
1283
+ sign_option : _,
1264
1284
} = options;
1265
1285
1266
1286
if !force_on_disk {
0 commit comments