Skip to content

Commit 407ab79

Browse files
committed
cargo-rail: scaffold 'workspace' mode for combined split; added test repo code
1 parent 617bb9d commit 407ab79

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ AGENTS.md
2323
*.key
2424

2525
# Cargo-Rail (Testing)
26-
rail.toml
26+
*rail.toml
27+
2728
# Notes
2829
STATUS.md
2930
E2E_TESTING_SETUP.md

crates/cargo-rail/src/commands/init.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::{self, Write};
33
use std::path::{Path, PathBuf};
44

55
use crate::cargo::metadata::WorkspaceMetadata;
6-
use crate::core::config::{CratePath, RailConfig, SplitConfig, SplitMode};
6+
use crate::core::config::{CratePath, RailConfig, SplitConfig, SplitMode, WorkspaceMode};
77
use crate::core::error::{RailError, RailResult, ResultExt};
88

99
/// Run the init command to set up cargo-rail configuration
@@ -99,6 +99,7 @@ pub fn run_init(all: bool) -> RailResult<()> {
9999
remote: String::new(), // Empty - user will fill this in
100100
branch: "main".to_string(),
101101
mode: SplitMode::Single,
102+
workspace_mode: WorkspaceMode::default(), // Standalone by default
102103
paths: vec![CratePath { path: package_path }],
103104
include: include_patterns,
104105
exclude: vec![],

crates/cargo-rail/src/core/config.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ pub struct SplitConfig {
7070
pub remote: String,
7171
pub branch: String,
7272
pub mode: SplitMode,
73+
/// For combined mode: how to structure the split repo
74+
#[serde(default)]
75+
pub workspace_mode: WorkspaceMode,
7376
#[serde(default)]
7477
pub paths: Vec<CratePath>,
7578
#[serde(default)]
@@ -84,13 +87,25 @@ pub struct CratePath {
8487
pub path: PathBuf,
8588
}
8689

87-
#[derive(Debug, Clone, Serialize, Deserialize)]
90+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8891
#[serde(rename_all = "lowercase")]
8992
pub enum SplitMode {
93+
#[default]
9094
Single,
9195
Combined,
9296
}
9397

98+
/// How to structure a combined split repository
99+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
100+
#[serde(rename_all = "lowercase")]
101+
pub enum WorkspaceMode {
102+
/// Multiple standalone crates in one repo (no workspace structure)
103+
#[default]
104+
Standalone,
105+
/// Workspace structure with root Cargo.toml (mirrors monorepo)
106+
Workspace,
107+
}
108+
94109
impl RailConfig {
95110
/// Find config file in search order: rail.toml, .rail.toml, .cargo/rail.toml, .config/rail.toml
96111
pub fn find_config_path(path: &Path) -> Option<PathBuf> {

crates/test-crate-b/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ pub fn feature_b1() -> &'static str {
3838
pub fn fix_b1() -> bool {
3939
true
4040
}
41+
pub fn sync_feature() -> &'static str { "Synced from monorepo" }

rail.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ name = "test-combined"
4848
remote = "[email protected]:loadingalias/cargo-rail-test-combined.git"
4949
branch = "main"
5050
mode = "combined"
51+
workspace_mode = "workspace" # "workspace" (mirror monorepo) or "standalone" (independent crates)
5152
include = [
5253
"src/**",
5354
"tests/**",

0 commit comments

Comments
 (0)