feat(source): support cherry-picking commits for git sources

- add source.cherry_pick (and cherry-pick alias) to package spec parsing/serialization
- apply listed cherry-picks in order after git checkout
- reject cherry_pick on non-git sources with explicit error
- include cherry_pick in interactive spec TOML output
- add parsing/behavior tests and update Source test fixtures
This commit is contained in:
2026-02-28 02:13:46 -06:00
parent 7e7bd84a43
commit 73a994ac53
15 changed files with 229 additions and 1 deletions
+18
View File
@@ -425,6 +425,7 @@ pub fn create_interactive() -> Result<PackageSpec> {
extract_dir,
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
};
if show_advanced {
@@ -791,6 +792,17 @@ pub fn spec_to_minimal_toml(spec: &PackageSpec) -> anyhow::Result<String> {
),
);
}
if !s.cherry_pick.is_empty() {
st.insert(
"cherry_pick".into(),
Value::Array(
s.cherry_pick
.iter()
.map(|rev| Value::String(rev.clone()))
.collect(),
),
);
}
arr.push(Value::Table(st));
}
root.insert("source".into(), Value::Array(arr));
@@ -1316,6 +1328,7 @@ mod tests {
extract_dir: "foo-1.0".into(),
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,
@@ -1365,6 +1378,7 @@ mod tests {
extract_dir: "foo-1.0".into(),
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,
@@ -1401,6 +1415,7 @@ mod tests {
extract_dir: "foo-1.0".into(),
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,
@@ -1464,6 +1479,7 @@ mod tests {
extract_dir: "foo-1.0".into(),
patches: vec!["fix.patch".into()],
post_extract: vec!["autoreconf -fi".into()],
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,
@@ -1525,6 +1541,7 @@ mod tests {
extract_dir: "$name-$version".into(),
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,
@@ -1560,6 +1577,7 @@ mod tests {
extract_dir: "foo-1.0".into(),
patches: Vec::new(),
post_extract: Vec::new(),
cherry_pick: Vec::new(),
}],
build: Build {
build_type: BuildType::Autotools,