Skip to content

Commit

Permalink
improved style
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunicorn committed Nov 5, 2021
1 parent 2547488 commit 446c518
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ fn make_pkg_predicate(
if skip.iter().any(|r| r.is_match(&name)) {
return false;
}
if !p.version().pre.is_empty() {
if ignore_pre_version.contains(&p.version().pre.as_str().to_owned()) {
return false;
}
if !p.version().pre.is_empty()
&& ignore_pre_version.contains(&p.version().pre.as_str().to_owned())
{
return false;
}
}

Expand Down Expand Up @@ -610,30 +610,27 @@ pub fn run(args: Opt) -> Result<(), Box<dyn Error>> {
let mut v = p.version().clone();
if v.pre.is_empty() {
v.pre = Prerelease::new("1").expect("Static will work");
} else if let Ok(num) = v.pre.as_str().parse::<u32>() {
v.pre = Prerelease::new(&format!("{}", num + 1))
.expect("Knwon to work");
} else {
if let Ok(num) = v.pre.as_str().parse::<u32>() {
v.pre = Prerelease::new(&format!("{}", num + 1))
.expect("Knwon to work");
let mut items = v
.pre
.as_str()
.split(".")
.map(|s| s.to_string())
.collect::<Vec<_>>();
if let Some(num) = items.last().and_then(|u| u.parse::<u32>().ok())
{
let _ = items.pop();
items.push(format!("{}", num + 1).to_owned());
} else {
items.push("1".to_owned());
}
if let Ok(pre) = Prerelease::new(&items.join(".")) {
v.pre = pre;
} else {
let mut items = v
.pre
.as_str()
.split(".")
.map(|s| s.to_string())
.collect::<Vec<_>>();
if let Some(num) =
items.last().and_then(|u| u.parse::<u32>().ok())
{
let _ = items.pop();
items.push(format!("{}", num + 1).to_owned());
} else {
items.push("1".to_owned());
}
if let Ok(pre) = Prerelease::new(&items.join(".")) {
v.pre = pre;
} else {
return None;
}
return None;
}
}
Some(v)
Expand Down

0 comments on commit 446c518

Please sign in to comment.