Run xtask command for the entire repo if diff fails
@@ -58,19 +58,31 @@ pub fn modified_files(scope: &Scope) -> ModifiedContent {
Scope::DiffToMain => Some("main".to_owned()),
};
- let files: Option<Vec<String>> = args.map(|args| {
- let vec = Command::new("git")
+ let files: Option<Vec<String>> = args
+ .and_then(|args| {
+ let output = Command::new("git")
.args(spread!["diff".to_owned(), "--name-only".to_owned(), args,])
.output()
- .expect("could not get modified files")
- .stdout;
+ .expect("could not get modified files");
+
+ if output.status.success() {
+ let vec = output.stdout;
// Extract the file names from the git output
+ Some(
String::from_utf8(vec)
.expect("could not convert to string")
.split('\n')
.map(|s| format!("./{}", s))
- .collect()
+ .collect(),
+ )
+ } else {
+ eprintln!(
+ "WARN: git diff failed with error ({}), running the command for the entire code base.",
+ output.status
+ );
+ None
+ }
});
// If something is changed in a Dockerfile, we'd want to run all CI steps, so set `files` to
