diff options
author | Nick Gerace <nickagerace@gmail.com> | 2020-12-15 21:41:39 -0500 |
---|---|---|
committer | Nick Gerace <nickagerace@gmail.com> | 2020-12-15 21:48:21 -0500 |
commit | 345d42e891aff14b371938ec571cee3657f9c8b4 (patch) | |
tree | ce6158ff356f3098660666186df5c3971ebbb3be /src/util.rs | |
parent | 19ac8540e29e3a8cce7ea1a95ed90a701ae6e99e (diff) | |
download | gfold-345d42e891aff14b371938ec571cee3657f9c8b4.zip |
Add disable unpushed commit check
Add disable unpushed commit check to give users a choice. The unpushed
function currently does not account for every case, so having the flag
is a temporary solution that may also provide useful in its own right.
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/util.rs b/src/util.rs index f6ea66e..6dda677 100644 --- a/src/util.rs +++ b/src/util.rs @@ -23,6 +23,7 @@ enum Condition { pub fn create_table_from_paths( repos: Vec<PathBuf>, path: &Path, + disable_unpushed_check: &bool, no_color: &bool, ) -> Option<driver::TableWrapper> { let mut table = prettytable::Table::new(); @@ -76,7 +77,7 @@ pub fn create_table_from_paths( let mut opts = git2::StatusOptions::new(); let condition = match repo_obj.statuses(Some(&mut opts)) { Ok(statuses) if statuses.is_empty() => { - if is_unpushed(&repo_obj, &head) { + if !disable_unpushed_check && is_unpushed(&repo_obj, &head) { Condition::Unpushed } else { Condition::Clean @@ -139,15 +140,23 @@ fn is_unpushed(repo: &git2::Repository, head: &git2::Reference) -> bool { } }; debug!("[+] local commit: {:#?}", local.id()); + if let Some(name) = head.name() { + debug!("[+] local ref: {}", name); + } let upstream = match repo.resolve_reference_from_short_name("origin") { - Ok(reference) => match reference.peel_to_commit() { - Ok(upstream) => upstream, - Err(e) => { - debug!("[-] error: {}", e); - return false; + Ok(reference) => { + if let Some(name) = reference.name() { + debug!("[+] origin ref: {}", name); + } + match reference.peel_to_commit() { + Ok(upstream) => upstream, + Err(e) => { + debug!("[-] error: {}", e); + return false; + } } - }, + } Err(e) => { debug!("[-] error: {}", e); return false; |