Make ep split-commit respect --failed=skip (#47150)

Release Notes:

- N/A
This commit is contained in:
Oleksiy Syvokon authored and GitHub committed 2026-01-19 17:26:41 +02:00
1 parent 4759bf9abe
commit 70fa46e41b
2 files changed
+51 -22

No files matched your search

+45 -19
View File
@@ -4,6 +4,7 @@
//! chronologically-ordered unified diff (a "commit").
//!
//! TODO: Port Python code to generate chronologically-ordered commits
use crate::FailedHandling;
use crate::reorder_patch::{Patch, PatchLine, extract_edits, locate_edited_line};
/// Find the largest valid UTF-8 char boundary at or before `index` in `s`.
@@ -116,6 +117,7 @@ pub fn run_split_commit(
args: &SplitCommitArgs,
inputs: &[PathBuf],
output_path: Option<&PathBuf>,
failed: FailedHandling,
) -> Result<()> {
use std::collections::HashSet;
use std::io::BufRead;
@@ -158,22 +160,34 @@ pub fn run_split_commit(
for sample_idx in 0..num_samples {
let sample_seed = base_seed.wrapping_add(sample_idx as u64);
let case = generate_evaluation_example_from_ordered_commit(
let case = match generate_evaluation_example_from_ordered_commit(
&annotated.reordered_commit,
&annotated.repo_url,
&annotated.commit_sha,
None, // Use random split point for multi-sample mode
Some(sample_seed),
Some(sample_idx),
)
.with_context(|| {
format!(
"failed to generate evaluation example for commit {} at line {} (sample {})",
annotated.commit_sha,
line_num + 1,
sample_idx
)
})?;
) {
Ok(case) => case,
Err(e) => {
let err_msg = format!(
"failed to generate evaluation example for commit {} at line {} (sample {}): {}",
annotated.commit_sha,
line_num + 1,
sample_idx,
e
);
match failed {
FailedHandling::Skip => {
eprintln!("{}", err_msg);
continue;
}
FailedHandling::Keep => {
anyhow::bail!(err_msg);
}
}
}
};
let json = if args.pretty {
serde_json::to_string_pretty(&case)
@@ -188,21 +202,33 @@ pub fn run_split_commit(
}
}
} else {
let case = generate_evaluation_example_from_ordered_commit(
let case = match generate_evaluation_example_from_ordered_commit(
&annotated.reordered_commit,
&annotated.repo_url,
&annotated.commit_sha,
split_point.clone(),
args.seed,
None,
)
.with_context(|| {
format!(
"failed to generate evaluation example for commit {} at line {}",
annotated.commit_sha,
line_num + 1
)
})?;
) {
Ok(case) => case,
Err(e) => {
let err_msg = format!(
"failed to generate evaluation example for commit {} at line {}: {}",
annotated.commit_sha,
line_num + 1,
e
);
match failed {
FailedHandling::Skip => {
eprintln!("{}", err_msg);
continue;
}
FailedHandling::Keep => {
anyhow::bail!(err_msg);
}
}
}
};
let json = if args.pretty {
serde_json::to_string_pretty(&case)