Skip to content

Commit 599dc82

Browse files
committed
Simplify get_git_modified_files
It only ever returned `Some`, so `Option` was useless in its return type.
1 parent c4b38a5 commit 599dc82

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

src/bootstrap/src/core/build_steps/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
9494
return Ok(None);
9595
}
9696

97-
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
97+
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"]).map(Some)
9898
}
9999

100100
#[derive(serde_derive::Deserialize)]

src/build_helper/src/git.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn get_git_modified_files(
173173
config: &GitConfig<'_>,
174174
git_dir: Option<&Path>,
175175
extensions: &[&str],
176-
) -> Result<Option<Vec<String>>, String> {
176+
) -> Result<Vec<String>, String> {
177177
let merge_base = get_closest_merge_commit(git_dir, config, &[])?;
178178

179179
let mut git = Command::new("git");
@@ -195,7 +195,7 @@ pub fn get_git_modified_files(
195195
}
196196
})
197197
.collect();
198-
Ok(Some(files))
198+
Ok(files)
199199
}
200200

201201
/// Returns the files that haven't been added to git yet.

src/tools/compiletest/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,7 @@ fn modified_tests(config: &Config, dir: &Path) -> Result<Vec<PathBuf>, String> {
747747
}
748748

749749
let files =
750-
get_git_modified_files(&config.git_config(), Some(dir), &vec!["rs", "stderr", "fixed"])?
751-
.unwrap_or(vec![]);
750+
get_git_modified_files(&config.git_config(), Some(dir), &vec!["rs", "stderr", "fixed"])?;
752751
// Add new test cases to the list, it will be convenient in daily development.
753752
let untracked_files = get_git_untracked_files(&config.git_config(), None)?.unwrap_or(vec![]);
754753

src/tools/suggest-tests/src/main.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ fn main() -> ExitCode {
1414
&Vec::new(),
1515
);
1616
let modified_files = match modified_files {
17-
Ok(Some(files)) => files,
18-
Ok(None) => {
19-
eprintln!("git error");
20-
return ExitCode::FAILURE;
21-
}
17+
Ok(files) => files,
2218
Err(err) => {
2319
eprintln!("Could not get modified files from git: \"{err}\"");
2420
return ExitCode::FAILURE;

0 commit comments

Comments
 (0)