aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-26 00:10:35 -0400
committerJesse Luehrs <doy@tozt.net>2023-03-26 00:10:35 -0400
commit93e6a9a08aec3cbb8b847a815ad905aa0d0bffca (patch)
tree9c9d3922475e846bd11293d91ddee36b56302355 /src/vcs
parentf252f4c6595421339cb3119f1ca8ef491077f365 (diff)
downloadfancy-prompt-93e6a9a08aec3cbb8b847a815ad905aa0d0bffca.tar.gz
fancy-prompt-93e6a9a08aec3cbb8b847a815ad905aa0d0bffca.zip
fmt
Diffstat (limited to 'src/vcs')
-rw-r--r--src/vcs/git.rs31
-rw-r--r--src/vcs/mod.rs12
2 files changed, 18 insertions, 25 deletions
diff --git a/src/vcs/git.rs b/src/vcs/git.rs
index 5b8ad96..1a5b856 100644
--- a/src/vcs/git.rs
+++ b/src/vcs/git.rs
@@ -38,8 +38,7 @@ impl GitInfo {
if true {
// XXX
status_options.update_index(true);
- }
- else {
+ } else {
status_options.update_index(false);
status_options.no_refresh(true);
}
@@ -73,8 +72,7 @@ impl GitInfo {
let branch = head.ok().and_then(|head| {
if head.is_branch() {
head.shorthand().map(|s| s.to_string())
- }
- else {
+ } else {
head.resolve().ok().and_then(|head| head.target()).map(
|oid| {
let mut sha = String::new();
@@ -109,16 +107,10 @@ impl GitInfo {
};
talk_about_time!("active operation");
- let remote_branch_diff = git.head()
+ let remote_branch_diff = git
+ .head()
.ok()
- .and_then(|head| {
- if head.is_branch() {
- Some(head)
- }
- else {
- None
- }
- })
+ .and_then(|head| if head.is_branch() { Some(head) } else { None })
.and_then(|head| head.resolve().ok())
.map(|head| {
(head.target(), head.shorthand().map(|s| s.to_string()))
@@ -128,11 +120,11 @@ impl GitInfo {
name.and_then(|name| {
git.refname_to_id(
&(String::from("refs/remotes/origin/") + &name),
- ).ok()
- .and_then(|remote_id| {
- git.graph_ahead_behind(head_id, remote_id)
- .ok()
- })
+ )
+ .ok()
+ .and_then(|remote_id| {
+ git.graph_ahead_behind(head_id, remote_id).ok()
+ })
})
})
});
@@ -195,8 +187,7 @@ pub fn detect() -> Option<Box<dyn super::VcsInfo>> {
if let Some(git) = git {
Some(Box::new(GitInfo::new(&git)))
- }
- else {
+ } else {
None
}
}
diff --git a/src/vcs/mod.rs b/src/vcs/mod.rs
index e672ec6..f033d2c 100644
--- a/src/vcs/mod.rs
+++ b/src/vcs/mod.rs
@@ -27,9 +27,12 @@ pub trait VcsInfo {
fn is_dirty(&self) -> bool {
let diff = self.remote_branch_diff();
- self.has_modified_files() || self.has_staged_files()
- || self.has_new_files() || !diff.is_some()
- || diff.map(|(local, remote)| local > 0 || remote > 0)
+ self.has_modified_files()
+ || self.has_staged_files()
+ || self.has_new_files()
+ || !diff.is_some()
+ || diff
+ .map(|(local, remote)| local > 0 || remote > 0)
.unwrap_or(false)
}
@@ -41,8 +44,7 @@ pub trait VcsInfo {
pub fn detect() -> Option<Box<dyn VcsInfo>> {
if let Some(git) = git::detect() {
Some(git)
- }
- else {
+ } else {
None
}
}