summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorNick Gerace <nickagerace@gmail.com>2021-01-27 02:06:29 +0000
committerNick Gerace <nickagerace@gmail.com>2021-01-26 21:11:18 -0500
commit09c88901cbc9d4507aad348391631106d41141a9 (patch)
tree1312eeceed02c39f06f60e9b30bacdb7af048a40 /src/util.rs
parent7bdeb4bd22706fa5363196486d023b722e756bae (diff)
downloadgfold-09c88901cbc9d4507aad348391631106d41141a9.zip
Switch disable unpushed check to enable
Switch disable unpushed check to enable. Change macOS to darwin where possible.
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/util.rs b/src/util.rs
index 6dda677..86a09d5 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,10 +6,8 @@
*/
use crate::driver;
-
-use std::path::{Path, PathBuf};
-
use log::debug;
+use std::path::{Path, PathBuf};
#[derive(Debug)]
enum Condition {
@@ -23,7 +21,7 @@ enum Condition {
pub fn create_table_from_paths(
repos: Vec<PathBuf>,
path: &Path,
- disable_unpushed_check: &bool,
+ enable_unpushed_check: &bool,
no_color: &bool,
) -> Option<driver::TableWrapper> {
let mut table = prettytable::Table::new();
@@ -54,30 +52,25 @@ pub fn create_table_from_paths(
continue;
}
};
- let url = match origin.url() {
- Some(url) => url,
- None => "none",
- };
+ let url = origin.url().unwrap_or("none");
debug!("[+] url: {:#?}", url);
let head = repo_obj.head().ok()?;
- let branch = match head.shorthand() {
- Some(branch) => branch,
- None => "none",
- };
+ let branch = head.shorthand().unwrap_or("none");
debug!("[+] branch: {:#?}", branch);
- let name = match Path::new(&repo).strip_prefix(path).ok()?.to_str() {
- Some(name) => name,
- None => "none",
- };
+ let name = Path::new(&repo)
+ .strip_prefix(path)
+ .ok()?
+ .to_str()
+ .unwrap_or("none");
debug!("[+] name: {:#?}", name);
// FIXME: test using the "is_bare()" method for a repository object.
let mut opts = git2::StatusOptions::new();
let condition = match repo_obj.statuses(Some(&mut opts)) {
Ok(statuses) if statuses.is_empty() => {
- if !disable_unpushed_check && is_unpushed(&repo_obj, &head) {
+ if *enable_unpushed_check && is_unpushed(&repo_obj, &head) {
Condition::Unpushed
} else {
Condition::Clean