Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/build_helper/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ pub fn get_git_modified_files(
let files = output_result(git.args(["diff-index", "--name-status", merge_base.trim()]))?
.lines()
.filter_map(|f| {
let (status, name) = f.trim().split_once(char::is_whitespace).unwrap();
let (status, name) = f.trim().split_once(char::is_whitespace)?;
if status == "D" {
None
} else if Path::new(name).extension().map_or(extensions.is_empty(), |ext| {
// If there is no extension, we allow the path if `extensions` is empty
// If there is an extension, we allow it if `extension` is empty or it contains the
// extension.
extensions.is_empty() || extensions.contains(&ext.to_str().unwrap())
extensions.is_empty()
|| ext.to_str().map_or(false, |ext_str| extensions.contains(&ext_str))
}) {
Some(name.to_owned())
} else {
Expand Down
8 changes: 7 additions & 1 deletion src/build_helper/src/stage0_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ pub fn parse_stage0_file() -> Stage0 {
continue;
}

let (key, value) = line.split_once('=').unwrap();
let (key, value) = match line.split_once('=') {
Some((k, v)) => (k, v),
None => {
println!("Warning: Skipping malformed config line {}", line);
continue;
}
};
Comment on lines +42 to +48
Copy link
Author

@marcusDenslow marcusDenslow Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping malformed stage0 config lines with a warning might hide real issues in the user's stage0 config.
Would it be better to fail with a proper error message here instead (e.g. bail! or return Err(...)), so the user knows right away their config is broken?

small note: the warning currently uses println! We might want to change this to eprintln! so that it goes to stderr. open to feedback on whats prefferable


match key {
"dist_server" => stage0.config.dist_server = value.to_owned(),
Expand Down
8 changes: 7 additions & 1 deletion src/build_helper/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ pub fn parse_gitmodules(target_dir: &Path) -> Vec<String> {
let gitmodules = target_dir.join(".gitmodules");
assert!(gitmodules.exists(), "'{}' file is missing.", gitmodules.display());

let file = File::open(gitmodules).unwrap();
let file = match File::open(&gitmodules) {
Ok(f) => f,
Err(_) => {
eprintln!("Warning: Could not open .gitmodules file at {}", gitmodules.display());
return Vec::new();
}
};

let mut submodules_paths = vec![];
for line in BufReader::new(file).lines().map_while(Result::ok) {
Expand Down
Loading