Skip to content

Commit

Permalink
Merge pull request #1 from messense/fix-segment
Browse files Browse the repository at this point in the history
Fix two crash
  • Loading branch information
reujab authored Jul 10, 2018
2 parents e8225ac + 79bd7b0 commit cf511bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/modules/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ pub fn segment(segment: &mut Segment, _: &[&str]) {
branch = head.shorthand().unwrap().to_owned();

let local = head.target().unwrap();
let upstream = repo.find_branch(&branch, git2::BranchType::Local).unwrap();
let upstream = upstream.upstream().unwrap().get().target().unwrap();

let (ahead, behind) = repo.graph_ahead_behind(local, upstream).unwrap();
graph = icons::get("ahead").repeat(ahead) + &icons::get("behind").repeat(behind);
let local_branch = repo.find_branch(&branch, git2::BranchType::Local).unwrap();
let upstream = local_branch.upstream();
if let Ok(upstream) = upstream {
if let Some(upstream) = upstream.get().target() {
let (ahead, behind) = repo.graph_ahead_behind(local, upstream).unwrap();
graph = icons::get("ahead").repeat(ahead) + &icons::get("behind").repeat(behind);
}
}
}

let mut modified = String::new();
Expand Down
4 changes: 3 additions & 1 deletion src/modules/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub fn segment(segment: &mut Segment, _: &[&str]) {
}

if let Ok(jobs) = env::var("jobs") {
segment.value += &icons::get("job").repeat(usize::from_str_radix(&jobs, 10).unwrap());
if let Ok(jobs_count) = usize::from_str_radix(jobs.trim(), 10) {
segment.value += &icons::get("job").repeat(jobs_count);
}
}
}

0 comments on commit cf511bc

Please sign in to comment.