-
-
Notifications
You must be signed in to change notification settings - Fork 260
/
mod.rs
31 lines (28 loc) · 907 Bytes
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mod explain;
pub use explain::explain;
pub mod parse;
pub use parse::function::parse;
mod previous_branches {
use crate::OutputFormat;
use anyhow::Context;
use git_repository as git;
pub fn function(repo: git::Repository, mut out: impl std::io::Write, format: OutputFormat) -> anyhow::Result<()> {
let branches = repo
.head()?
.prior_checked_out_branches()?
.context("The reflog for HEAD is required")?;
match format {
OutputFormat::Human => {
for (name, id) in branches {
writeln!(out, "{} {}", id, name)?;
}
}
#[cfg(feature = "serde1")]
OutputFormat::Json => {
serde_json::to_writer_pretty(&mut out, &branches)?;
}
}
Ok(())
}
}
pub use previous_branches::function as previous_branches;