Skip to content

Commit

Permalink
refactor: use matches expression instead of if lets
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Nov 30, 2021
1 parent 43eba56 commit 7b7e469
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions src/git/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ impl Repository {
let mut options = DiffOptions::new();
options.include_untracked(include_untracked);

let diff = if let Some(head) = &self.get_head() {
self.0
.diff_tree_to_index(head.as_tree(), None, Some(&mut options))
} else {
self.0
.diff_tree_to_workdir_with_index(None, Some(&mut options))
let diff = match &self.get_head() {
Some(head) => self
.0
.diff_tree_to_index(head.as_tree(), None, Some(&mut options)),
None => self
.0
.diff_tree_to_workdir_with_index(None, Some(&mut options)),
};

if let Ok(diff) = diff {
if diff.deltas().len() > 0 {
Some(diff)
} else {
None
match diff {
Ok(diff) => {
if diff.deltas().len() > 0 {
Some(diff)
} else {
None
}
}
} else {
None
Err(..) => None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl CocoGitto {
// Remove merge commits
.filter(|commit| !commit.message().unwrap_or("").starts_with("Merge"))
.filter(|commit| filters.filter_git2_commit(commit))
.map(|commit| Commit::from_git_commit(commit))
.map(Commit::from_git_commit)
// Apply filters
.filter(|commit| match commit {
Ok(commit) => filters.filters(commit),
Expand Down

0 comments on commit 7b7e469

Please sign in to comment.