Skip to content

Commit

Permalink
fix ahead-behind
Browse files Browse the repository at this point in the history
minor bump
  • Loading branch information
ChrisDavison committed Feb 23, 2024
1 parent 390076c commit 3255337
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "repoutil"
version = "0.25.0"
version = "0.26.0"
authors = ["Chris Davison <c.jr.davison@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
12 changes: 5 additions & 7 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,14 @@ pub fn stat(p: &Path, as_json: bool) -> Result<Option<String>> {
fn ahead_behind(p: &Path) -> Result<Option<String>> {
let response: String = command_output(
p,
"for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads",
)?
.iter()
.map(|x| x.trim_matches('\'').trim())
.filter(|x| x.split(' ').nth(1).is_some())
.collect();
"status --porcelain --ahead-behind -b",
)?.into_iter().next().filter(|x| x.contains("[")).unwrap_or(String::new());
Ok(if response.is_empty() {
None
} else {
Some(response)
let start = response.find('[').unwrap();
let end = response.find(']').unwrap();
Some(response[start + 1..end].to_string())
})
}

Expand Down

0 comments on commit 3255337

Please sign in to comment.