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