Allow to interdiff with a pre-made ref

This commit is contained in:
Quentin Boyer 2025-01-14 14:31:48 +01:00
parent 2fc6af4390
commit e9a3c9a6b0

View file

@ -238,6 +238,13 @@ struct FormatPatch {
help = "Reference for the interdiff (defaults to ${config.interdiff_base})"
)]
base_diff: Option<String>,
#[arg(
short = 'D',
long,
help = "Perform the interdiff with an explicit reference",
conflicts_with = "diff"
)]
diff_to: Option<String>,
extra_args: Vec<String>,
}
@ -345,7 +352,10 @@ impl FormatPatch {
})
};
let _version_dir = if let Some(interdiff) = self.diff {
let _version_dir = match (self.diff, self.diff_to) {
(None, None) => format_patch(&[])?,
(Some(_), Some(_)) => unreachable!(),
(Some(patch_version), None) => {
let base = self
.base_diff
.or(config.interdiff_base)
@ -411,7 +421,7 @@ impl FormatPatch {
wt.exec(&["switch", branch.name])?;
let patches = branch_dir
.join(&interdiff.to_string())
.join(&patch_version.to_string())
.read_dir()
.into_diagnostic()
.wrap_err("Could not read interdiff folder")?
@ -439,8 +449,10 @@ impl FormatPatch {
let interdiff_branch = format!("--interdiff={}", branch.name);
format_patch(&[&interdiff_branch])?
} else {
format_patch(&[])?
}
(None, Some(diff_to)) => {
format_patch(&[&format!("--interdiff={diff_to}")])?
},
};
let cover_letter = branch_dir.join(COVER_LETTER_NAME);