-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
398 changed files
with
4,727 additions
and
628 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,5 +1,3 @@ | ||
use std::convert::TryInto; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
enum Error { | ||
#[error(transparent)] | ||
|
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
Oops, something went wrong.