feat: add exit-code to link check
This commit is contained in:
@@ -2,8 +2,10 @@ use std::cell::Cell;
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::io::{self, Write};
|
||||
use std::os::unix::fs::symlink;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process;
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
@@ -62,7 +64,7 @@ fn warn(msg: impl std::fmt::Display) {
|
||||
}
|
||||
|
||||
// list untracked paths not in the store, i.e. what a sandbox can still read
|
||||
pub fn check(paths: &[PathBuf], porcelain: bool, null: bool) -> Result<()> {
|
||||
pub fn check(paths: &[PathBuf], porcelain: bool, null: bool, exit_code: bool) -> Result<()> {
|
||||
let repo = Repo::discover()?;
|
||||
let pathspecs = relative_pathspecs(&repo, paths)?;
|
||||
|
||||
@@ -89,6 +91,12 @@ pub fn check(paths: &[PathBuf], porcelain: bool, null: bool) -> Result<()> {
|
||||
print_listing(&repo, &exposed);
|
||||
}
|
||||
|
||||
// git's --exit-code convention: nothing to report is 0, anything is 1
|
||||
if exit_code && !exposed.is_empty() {
|
||||
io::stdout().flush().context("writing the listing")?;
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user