feat!: report findings with exit code 4, not the code for failure
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use fs_err::{read_dir, read_link};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitCode;
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
|
||||
@@ -9,14 +8,14 @@ use crate::cmd::{Cmd, LsFiles};
|
||||
use crate::ctx::Ctx;
|
||||
use crate::output::{line, text};
|
||||
|
||||
// whether anything is outside the store, which main turns into an exit code
|
||||
pub fn check(
|
||||
ctx: &Ctx,
|
||||
paths: &[PathBuf],
|
||||
porcelain: bool,
|
||||
null: bool,
|
||||
exit_code: bool,
|
||||
store: Option<&Path>,
|
||||
) -> Result<ExitCode> {
|
||||
) -> Result<bool> {
|
||||
let repo = Repo::discover(ctx, store)?;
|
||||
let pathspecs = relative_pathspecs(&repo, paths)?;
|
||||
|
||||
@@ -43,19 +42,12 @@ pub fn check(
|
||||
print_listing(&repo, &exposed);
|
||||
}
|
||||
|
||||
// git's --exit-code convention: nothing to report is 0, anything is 1
|
||||
if exit_code && !exposed.is_empty() {
|
||||
return Ok(ExitCode::FAILURE);
|
||||
}
|
||||
|
||||
Ok(ExitCode::SUCCESS)
|
||||
Ok(!exposed.is_empty())
|
||||
}
|
||||
|
||||
fn print_porcelain(exposed: &[Exposed], null: bool) {
|
||||
let end = if null { '\0' } else { '\n' };
|
||||
// a filename can hold an arrow but not a NUL, so -z separates the two paths
|
||||
// with one the way `git status -z` does for a rename. the two character code
|
||||
// stays where it is: it cannot be mistaken for part of a path
|
||||
// a filename can hold an arrow but not a NUL, as `git status -z` also assumes
|
||||
let between = if null { "\0" } else { " -> " };
|
||||
|
||||
for item in exposed {
|
||||
|
||||
Reference in New Issue
Block a user