-
-
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.
It's a good way to compare the time it takes to run a full status compared to a quick is-dirty check.
- Loading branch information
Showing
4 changed files
with
53 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::OutputFormat; | ||
use anyhow::bail; | ||
|
||
pub enum Mode { | ||
IsClean, | ||
IsDirty, | ||
} | ||
|
||
pub fn check( | ||
repo: gix::Repository, | ||
mode: Mode, | ||
out: &mut dyn std::io::Write, | ||
format: OutputFormat, | ||
) -> anyhow::Result<()> { | ||
if format != OutputFormat::Human { | ||
bail!("JSON output isn't implemented yet"); | ||
} | ||
let is_dirty = repo.is_dirty()?; | ||
let res = match (is_dirty, mode) { | ||
(false, Mode::IsClean) => Ok("The repository is clean"), | ||
(true, Mode::IsClean) => Err("The repository has changes"), | ||
(false, Mode::IsDirty) => Err("The repository is clean"), | ||
(true, Mode::IsDirty) => Ok("The repository has changes"), | ||
}; | ||
|
||
let suffix = "(not counting untracked files)"; | ||
match res { | ||
Ok(msg) => writeln!(out, "{msg} {suffix}")?, | ||
Err(msg) => bail!("{msg} {suffix}"), | ||
} | ||
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