Skip to content

Commit a975551

Browse files
authored
fix(cli): duplicated short flag for signer sign, closes #3483 (#3492)
1 parent 84895a9 commit a975551

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Fixes the signature of the `signer sign` command to not have duplicated short flags.

examples/api/src-tauri/Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/cli/src/helpers/updater_signature.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ where
102102
/// Sign files
103103
pub fn sign_file<P>(
104104
private_key: String,
105-
password: String,
105+
password: Option<String>,
106106
bin_path: P,
107107
) -> crate::Result<(PathBuf, String)>
108108
where
109109
P: AsRef<Path>,
110110
{
111111
let decoded_secret = decode_key(private_key)?;
112112
let sk_box = SecretKeyBox::from_string(&decoded_secret).unwrap();
113-
let sk = sk_box.into_secret_key(Some(password)).unwrap();
113+
let sk = sk_box.into_secret_key(password).unwrap();
114114

115115
// We need to append .sig at the end it's where the signature will be stored
116116
let signature_path_string = format!("{}.sig", bin_path.as_ref().display());
@@ -146,10 +146,8 @@ where
146146
P: AsRef<Path>,
147147
{
148148
// if no password provided we set empty string
149-
let password_string = match var_os("TAURI_KEY_PASSWORD") {
150-
Some(value) => String::from(value.to_str().unwrap()),
151-
None => "".into(),
152-
};
149+
let password_string =
150+
var_os("TAURI_KEY_PASSWORD").map(|value| value.to_str().unwrap().to_string());
153151
// get the private key
154152
if let Some(private_key) = var_os("TAURI_PRIVATE_KEY") {
155153
// check if this file exist..

tooling/cli/src/signer/sign.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ pub struct Options {
2424
#[clap(short, long)]
2525
password: Option<String>,
2626
/// Sign the specified file
27-
#[clap(short, long)]
28-
file: Option<PathBuf>,
27+
file: PathBuf,
2928
}
3029

3130
pub fn command(mut options: Options) -> Result<()> {
@@ -34,22 +33,20 @@ pub fn command(mut options: Options) -> Result<()> {
3433
} else {
3534
options.private_key
3635
};
37-
if options.private_key.is_none() {
36+
let private_key = if let Some(pk) = options.private_key {
37+
pk
38+
} else {
3839
return Err(anyhow::anyhow!(
3940
"Key generation aborted: Unable to find the private key".to_string(),
4041
));
41-
}
42+
};
4243

4344
if options.password.is_none() {
4445
println!("Signing without password.");
4546
}
4647

47-
let (manifest_dir, signature) = sign_file(
48-
options.private_key.unwrap(),
49-
options.password.unwrap(),
50-
options.file.unwrap(),
51-
)
52-
.with_context(|| "failed to sign file")?;
48+
let (manifest_dir, signature) = sign_file(private_key, options.password, options.file)
49+
.with_context(|| "failed to sign file")?;
5350

5451
println!(
5552
"\nYour file was signed successfully, You can find the signature here:\n{}\n\nPublic signature:\n{}\n\nMake sure to include this into the signature field of your update server.",

0 commit comments

Comments
 (0)