@@ -116,6 +116,7 @@ impl Commit {
116116
117117pub struct GitRepo {
118118 repo : git2:: Repository ,
119+ sign : Option < git2_ext:: ops:: UserSign > ,
119120 push_remote : Option < String > ,
120121 pull_remote : Option < String > ,
121122 commits : std:: cell:: RefCell < std:: collections:: HashMap < git2:: Oid , std:: rc:: Rc < Commit > > > ,
@@ -128,6 +129,7 @@ impl GitRepo {
128129 pub fn new ( repo : git2:: Repository ) -> Self {
129130 Self {
130131 repo,
132+ sign : None ,
131133 push_remote : None ,
132134 pull_remote : None ,
133135 commits : Default :: default ( ) ,
@@ -137,6 +139,17 @@ impl GitRepo {
137139 }
138140 }
139141
142+ pub fn set_sign ( & mut self , yes : bool ) -> Result < ( ) , git2:: Error > {
143+ if yes {
144+ let config = self . repo . config ( ) ?;
145+ let sign = git2_ext:: ops:: UserSign :: from_config ( & self . repo , & config) ?;
146+ self . sign = Some ( sign) ;
147+ } else {
148+ self . sign = None ;
149+ }
150+ Ok ( ( ) )
151+ }
152+
140153 pub fn set_push_remote ( & mut self , remote : & str ) {
141154 self . push_remote = Some ( remote. to_owned ( ) ) ;
142155 }
@@ -401,11 +414,21 @@ impl GitRepo {
401414 }
402415
403416 pub fn reword ( & mut self , head_oid : git2:: Oid , msg : & str ) -> Result < git2:: Oid > {
404- git2_ext:: ops:: reword ( & self . repo , head_oid, msg, None )
417+ git2_ext:: ops:: reword (
418+ & self . repo ,
419+ head_oid,
420+ msg,
421+ self . sign . as_ref ( ) . map ( |s| s as & dyn git2_ext:: ops:: Sign ) ,
422+ )
405423 }
406424
407425 pub fn squash ( & mut self , head_id : git2:: Oid , into_id : git2:: Oid ) -> Result < git2:: Oid > {
408- git2_ext:: ops:: squash ( & self . repo , head_id, into_id, None )
426+ git2_ext:: ops:: squash (
427+ & self . repo ,
428+ head_id,
429+ into_id,
430+ self . sign . as_ref ( ) . map ( |s| s as & dyn git2_ext:: ops:: Sign ) ,
431+ )
409432 }
410433
411434 pub fn stash_push ( & mut self , message : Option < & str > ) -> Result < git2:: Oid > {
0 commit comments