Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make `ep split-commit` respect `--failed=skip` (#47150)
Oleksiy Syvokonf98acf4ca94a
diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rsindex d84541af456..c7128fdefc2 100644--- a/crates/edit_prediction_cli/src/main.rs+++ b/crates/edit_prediction_cli/src/main.rs@@ -470,9 +470,12 @@ fn main() {return;}Command::SplitCommit(split_commit_args) => {- if let Err(error) =- split_commit::run_split_commit(split_commit_args, &args.inputs, output.as_ref())- {+ if let Err(error) = split_commit::run_split_commit(+ split_commit_args,+ &args.inputs,+ output.as_ref(),+ args.failed,+ ) {eprintln!("{error:#}");std::process::exit(1);}diff --git a/crates/edit_prediction_cli/src/split_commit.rs b/crates/edit_prediction_cli/src/split_commit.rsindex b4c381193d4..a992f1af718 100644--- a/crates/edit_prediction_cli/src/split_commit.rs+++ b/crates/edit_prediction_cli/src/split_commit.rs@@ -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 modeSome(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)