Skip to content

Commit e0fcf77

Browse files
committed
cargo-rail: cleaning
1 parent 6eb566a commit e0fcf77

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rules.md
2727
cmd_cfg.md
2828
v1_precheck.md
2929
ARCHITECTURE.md
30+
final_testing.md
3031

3132
# Cargo-Rail (Testing)
3233
*rail.toml

src/cargo/manifest_ops/transform.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub fn resolve_package_workspace_inheritance(doc: &mut DocumentMut, workspace_pa
4545
"version",
4646
"authors",
4747
"edition",
48+
"rust-version",
4849
"license",
4950
"repository",
5051
"description",

src/commands/split.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ pub fn run_split_init(ctx: &WorkspaceContext, crates: Option<Vec<String>>, check
206206

207207
fs::write(&config_path, config_toml)?;
208208
println!("updated: {}", config_path.display());
209+
210+
println!("\nnext: review and customize the generated config");
211+
println!(" - edit 'remote' URLs to match your repositories");
212+
println!(" - for combined splits (multiple crates in one repo):");
213+
println!(" 1. set mode = \"combined\" on one crate");
214+
println!(" 2. add other crate paths to its 'paths' array");
215+
println!(" 3. remove the other crate entries");
209216
}
210217

211218
Ok(())

src/split/engine.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,52 @@ impl<'a> SplitEngine<'a> {
751751

752752
// Remove exclude if present (not needed for split repo)
753753
table.remove("exclude");
754+
755+
// Filter default-members to only include split crates (Issue #2)
756+
let members_set: std::collections::HashSet<&str> = members.iter().map(|s| s.as_str()).collect();
757+
if let Some(default_members) = table.get_mut("default-members")
758+
&& let Some(arr) = default_members.as_array_mut()
759+
{
760+
arr.retain(|item| item.as_str().map(|s| members_set.contains(s)).unwrap_or(false));
761+
}
762+
// Remove default-members if empty
763+
if table
764+
.get("default-members")
765+
.and_then(|d| d.as_array())
766+
.map(|a| a.is_empty())
767+
.unwrap_or(false)
768+
{
769+
table.remove("default-members");
770+
}
771+
772+
// Remove workspace.dependencies - split crates have inlined deps (Issue #4)
773+
table.remove("dependencies");
774+
}
775+
776+
// Filter profile package specs to only include split crates (Issue #3)
777+
let members_set: std::collections::HashSet<&str> = members.iter().map(|s| s.as_str()).collect();
778+
if let Some(profile) = doc.get_mut("profile").and_then(|p| p.as_table_mut()) {
779+
for (_, profile_section) in profile.iter_mut() {
780+
if let Some(profile_table) = profile_section.as_table_mut() {
781+
if let Some(pkg) = profile_table.get_mut("package").and_then(|p| p.as_table_mut()) {
782+
let pkg_names: Vec<String> = pkg.iter().map(|(k, _)| k.to_string()).collect();
783+
for pkg_name in pkg_names {
784+
if !members_set.contains(pkg_name.as_str()) {
785+
pkg.remove(&pkg_name);
786+
}
787+
}
788+
}
789+
// Remove empty package table
790+
if profile_table
791+
.get("package")
792+
.and_then(|p| p.as_table())
793+
.map(|t| t.is_empty())
794+
.unwrap_or(false)
795+
{
796+
profile_table.remove("package");
797+
}
798+
}
799+
}
754800
}
755801

756802
// Remove package section if present (virtual workspace)

0 commit comments

Comments
 (0)