-
-
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: support for listing worktrees with
gix worktree list
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ pub mod status; | |
pub mod submodule; | ||
pub mod tree; | ||
pub mod verify; | ||
pub mod worktree; |
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,28 @@ | ||
use crate::OutputFormat; | ||
use anyhow::bail; | ||
|
||
pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write, format: OutputFormat) -> anyhow::Result<()> { | ||
if format != OutputFormat::Human { | ||
bail!("JSON output isn't implemented yet"); | ||
} | ||
|
||
if let Some(worktree) = repo.worktree() { | ||
writeln!( | ||
out, | ||
"{base} [{branch}]", | ||
base = gix::path::realpath(worktree.base())?.display(), | ||
branch = repo | ||
.head_name()? | ||
.map_or("<detached>".into(), |name| name.shorten().to_owned()), | ||
)?; | ||
} | ||
for proxy in repo.worktrees()? { | ||
writeln!( | ||
out, | ||
"{base} [{name}]", | ||
base = proxy.base()?.display(), | ||
name = proxy.id() | ||
)?; | ||
} | ||
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