Skip to content

Commit 40ae04b

Browse files
committed
update test
1 parent d069623 commit 40ae04b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

asyncgit/src/sync/sign.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ enum SSHProgram {
173173

174174
impl SSHProgram {
175175
pub fn new(config: &git2::Config) -> Self {
176-
match config.get_string("gpg.ssh.program") {
176+
match dbg!(config.get_string("gpg.ssh.program")) {
177177
Err(_) => Self::Default,
178178
Ok(ssh_program) => {
179179
if ssh_program.is_empty() {
@@ -189,13 +189,13 @@ impl SSHProgram {
189189
config: &git2::Config,
190190
) -> Result<Box<dyn Sign>, SignBuilderError> {
191191
match self {
192-
SSHProgram::Default => {
192+
Self::Default => {
193193
let ssh_signer = ConfigAccess(config)
194194
.signing_key()
195195
.and_then(SSHSign::new)?;
196196
Ok(Box::new(ssh_signer))
197197
}
198-
SSHProgram::SystemBin(exec_path) => {
198+
Self::SystemBin(exec_path) => {
199199
let key = ConfigAccess(config).signing_key()?;
200200
Ok(Box::new(ExternalBinSSHSign::new(exec_path, key)))
201201
}
@@ -333,9 +333,10 @@ enum KeyPathOrLiteral {
333333

334334
impl KeyPathOrLiteral {
335335
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)
339340
}
340341
}
341342
}
@@ -346,8 +347,7 @@ impl Display for KeyPathOrLiteral {
346347
f: &mut std::fmt::Formatter<'_>,
347348
) -> std::fmt::Result {
348349
let buf = match self {
349-
Self::Literal(x) => x,
350-
Self::KeyPath(x) => x,
350+
Self::KeyPath(x) | Self::Literal(x) => x,
351351
};
352352
f.write_fmt(format_args!("{}", buf.display()))
353353
}
@@ -378,7 +378,7 @@ impl ExternalBinSSHSign {
378378
#[cfg(test)]
379379
let signing_key = key_path.to_string();
380380

381-
ExternalBinSSHSign {
381+
Self {
382382
program_path,
383383
key_path,
384384
#[cfg(test)]
@@ -490,7 +490,7 @@ impl SSHSign {
490490
})
491491
} else {
492492
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:?}"),
494494
))
495495
}
496496
}
@@ -630,15 +630,15 @@ mod tests {
630630

631631
{
632632
let mut config = repo.config()?;
633-
config.set_str("gpg.program", "ssh")?;
633+
config.set_str("gpg.format", "ssh")?;
634634
config.set_str("user.signingKey", "/tmp/key.pub")?;
635635
config.set_str("gpg.ssh.program", "/bin/cat")?;
636636
}
637637

638638
let sign =
639639
SignBuilder::from_gitconfig(&repo, &repo.config()?)?;
640640

641-
assert_eq!("/bin/cat", sign.program());
641+
assert_eq!("cat", sign.program());
642642
assert_eq!("/tmp/key.pub", sign.signing_key());
643643

644644
Ok(())

0 commit comments

Comments
 (0)