Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #45] Use sensible defaults instead of blindly unwrapping #47

Merged
merged 1 commit into from
May 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(slice_patterns)]
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
Expand Down Expand Up @@ -55,12 +54,11 @@ pub fn run() -> Result<i32> {
_ => true,
}
})
.unwrap();
.unwrap_or(&"");

let mut split_args = args.split(|x| x == command);
// Guaranteed two empty arrays, at minimum, so safe to unwrap
let global_args = split_args.next().unwrap();
let command_args = split_args.next().unwrap();
let global_args = split_args.next().unwrap_or(&[]);
let command_args = split_args.next().unwrap_or(&[]);

let code = if TRIGGERS.contains(command) {
match command_args {
Expand Down Expand Up @@ -233,6 +231,7 @@ impl<C: config::Config> GitTogether<C> {
.get(&namespaced("aliases"))
.unwrap_or_else(|_| String::new())
.split(',')
.filter(|s| s != &"")
.any(|a| a == cmd)
}

Expand Down