-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!:
gix rev resolve --explain
(#427)
- Loading branch information
Showing
6 changed files
with
49 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
mod explain; | ||
pub use explain::explain; | ||
|
||
pub mod parse; | ||
pub use parse::function::parse; | ||
pub mod resolve; | ||
pub use resolve::function::resolve; | ||
|
||
mod previous_branches { | ||
use anyhow::Context; | ||
use git_repository as git; | ||
|
||
use crate::OutputFormat; | ||
|
||
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(()) | ||
} | ||
} | ||
mod previous_branches; | ||
pub use previous_branches::function as previous_branches; |
23 changes: 23 additions & 0 deletions
23
gitoxide-core/src/repository/revision/previous_branches.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use anyhow::Context; | ||
use git_repository as git; | ||
|
||
use crate::OutputFormat; | ||
|
||
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters