Skip to content

Commit 841fb06

Browse files
committed
Not sure what I was thinking with this match
1 parent 652c73b commit 841fb06

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// #![allow(clippy::nonminimal_bool)]
2+
13
use cli::Gitpo;
24
use reqwest::StatusCode;
35
use std::process::exit;
@@ -28,7 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2830
let headers = result.headers();
2931
match status {
3032
StatusCode::OK | StatusCode::CREATED => {
31-
let apiloc = config.extract_url(&headers);
33+
let apiloc = config.extract_url(&headers);&& can_use_ssh)
3234
let (remote_url, can_use_ssh) = match (
3335
config.ssh_url(&headers),
3436
matches.is_present("ssh_remote_format"),
@@ -40,11 +42,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4042
let remote_name = matches
4143
.value_of("remote_name")
4244
.expect("This should default to origin, so something is wrong.");
43-
if matches.is_present("set_remote")
44-
&& ((matches.is_present("ssh_remote_format") && can_use_ssh) || !can_use_ssh)
45-
&& !add_remote(remote_name, &remote_url)
46-
{
47-
eprintln!("Couldn't set remote.");
45+
46+
if matches.is_present("set_remote") {
47+
if matches.is_present("ssh_remote_format") && !can_use_ssh {
48+
eprintln!("Can't use ssh format with this provider.");
49+
exit(22);
50+
}
51+
52+
if !add_remote(remote_name, &remote_url) {
53+
eprintln!("Failed to add remote.");
54+
exit(404);
55+
}
4856
}
4957
}
5058
StatusCode::UNPROCESSABLE_ENTITY | StatusCode::BAD_REQUEST => {

0 commit comments

Comments
 (0)