@@ -173,7 +173,7 @@ enum SSHProgram {
173
173
174
174
impl SSHProgram {
175
175
pub fn new ( config : & git2:: Config ) -> Self {
176
- match config. get_string ( "gpg.ssh.program" ) {
176
+ match dbg ! ( config. get_string( "gpg.ssh.program" ) ) {
177
177
Err ( _) => Self :: Default ,
178
178
Ok ( ssh_program) => {
179
179
if ssh_program. is_empty ( ) {
@@ -189,13 +189,13 @@ impl SSHProgram {
189
189
config : & git2:: Config ,
190
190
) -> Result < Box < dyn Sign > , SignBuilderError > {
191
191
match self {
192
- SSHProgram :: Default => {
192
+ Self :: Default => {
193
193
let ssh_signer = ConfigAccess ( config)
194
194
. signing_key ( )
195
195
. and_then ( SSHSign :: new) ?;
196
196
Ok ( Box :: new ( ssh_signer) )
197
197
}
198
- SSHProgram :: SystemBin ( exec_path) => {
198
+ Self :: SystemBin ( exec_path) => {
199
199
let key = ConfigAccess ( config) . signing_key ( ) ?;
200
200
Ok ( Box :: new ( ExternalBinSSHSign :: new ( exec_path, key) ) )
201
201
}
@@ -333,9 +333,10 @@ enum KeyPathOrLiteral {
333
333
334
334
impl KeyPathOrLiteral {
335
335
fn new ( buf : PathBuf ) -> Self {
336
- match buf. is_file ( ) {
337
- true => KeyPathOrLiteral :: KeyPath ( buf) ,
338
- false => KeyPathOrLiteral :: Literal ( buf) ,
336
+ if buf. is_file ( ) {
337
+ Self :: KeyPath ( buf)
338
+ } else {
339
+ Self :: Literal ( buf)
339
340
}
340
341
}
341
342
}
@@ -346,8 +347,7 @@ impl Display for KeyPathOrLiteral {
346
347
f : & mut std:: fmt:: Formatter < ' _ > ,
347
348
) -> std:: fmt:: Result {
348
349
let buf = match self {
349
- Self :: Literal ( x) => x,
350
- Self :: KeyPath ( x) => x,
350
+ Self :: KeyPath ( x) | Self :: Literal ( x) => x,
351
351
} ;
352
352
f. write_fmt ( format_args ! ( "{}" , buf. display( ) ) )
353
353
}
@@ -378,7 +378,7 @@ impl ExternalBinSSHSign {
378
378
#[ cfg( test) ]
379
379
let signing_key = key_path. to_string ( ) ;
380
380
381
- ExternalBinSSHSign {
381
+ Self {
382
382
program_path,
383
383
key_path,
384
384
#[ cfg( test) ]
@@ -490,7 +490,7 @@ impl SSHSign {
490
490
} )
491
491
} else {
492
492
Err ( SignBuilderError :: SSHSigningKey (
493
- format ! ( "Currently, we only support a pair of ssh key in disk. Found {:?}" , key ) ,
493
+ format ! ( "Currently, we only support a pair of ssh key in disk. Found {key :?}" ) ,
494
494
) )
495
495
}
496
496
}
@@ -630,15 +630,15 @@ mod tests {
630
630
631
631
{
632
632
let mut config = repo. config ( ) ?;
633
- config. set_str ( "gpg.program " , "ssh" ) ?;
633
+ config. set_str ( "gpg.format " , "ssh" ) ?;
634
634
config. set_str ( "user.signingKey" , "/tmp/key.pub" ) ?;
635
635
config. set_str ( "gpg.ssh.program" , "/bin/cat" ) ?;
636
636
}
637
637
638
638
let sign =
639
639
SignBuilder :: from_gitconfig ( & repo, & repo. config ( ) ?) ?;
640
640
641
- assert_eq ! ( "/bin/ cat" , sign. program( ) ) ;
641
+ assert_eq ! ( "cat" , sign. program( ) ) ;
642
642
assert_eq ! ( "/tmp/key.pub" , sign. signing_key( ) ) ;
643
643
644
644
Ok ( ( ) )
0 commit comments