Skip to content

Commit 19594cf

Browse files
committed
cargo-rail: cleaning it up
1 parent 9af5154 commit 19594cf

33 files changed

+35
-1573
lines changed

deny.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ignore = []
1616
allow = [
1717
"MIT",
1818
"Apache-2.0",
19-
"Apache-2.0 WITH LLVM-exception",
2019
"BSL-1.0",
2120
"Unicode-3.0",
2221
"Zlib",
@@ -30,12 +29,6 @@ wildcards = "allow"
3029
highlight = "all"
3130

3231
skip = [
33-
# Windows ecosystem - commonly has version mismatches across targets
34-
"windows-sys",
35-
"windows-targets",
36-
"windows_aarch64_msvc",
37-
"windows_x86_64_gnu",
38-
"windows_x86_64_msvc",
3932
# Low-level system dependencies - acceptable to have multiple versions
4033
# petgraph depends on hashbrown v0.15, while indexmap uses v0.16
4134
"hashbrown",

src/commands/affected.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
//! - Which crates transitively depend on those changed crates
66
//! - The minimal set of crates that need testing/building
77
8-
use crate::workspace::WorkspaceContext;
98
use crate::error::{RailError, RailResult};
109
use crate::git::SystemGit;
1110
use crate::graph::AffectedAnalysis;
11+
use crate::workspace::WorkspaceContext;
1212
use std::path::{Path, PathBuf};
1313

1414
/// Output format for affected command

src/commands/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
//! - `--workspace` to override and check all workspace crates
1010
//! - `--dry-run` to show the plan without executing
1111
12-
use crate::workspace::WorkspaceContext;
1312
use crate::error::{RailError, RailResult};
1413
use crate::git::SystemGit;
1514
use crate::graph::AffectedAnalysis;
15+
use crate::workspace::WorkspaceContext;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
1818

src/commands/clippy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
//! - `--workspace` to override and lint all workspace crates
1010
//! - `--dry-run` to show the plan without executing
1111
12-
use crate::workspace::WorkspaceContext;
1312
use crate::error::{RailError, RailResult};
1413
use crate::git::SystemGit;
1514
use crate::graph::AffectedAnalysis;
15+
use crate::workspace::WorkspaceContext;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
1818

src/commands/split.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::io::{self, Write};
22

3-
use crate::workspace::WorkspaceContext;
43
use crate::error::{ConfigError, RailError, RailResult};
54
use crate::plan::PlanExecutor;
65
use crate::plan::{Operation, OperationType, Plan};
76
use crate::utils;
7+
use crate::workspace::WorkspaceContext;
88
use rayon::prelude::*;
99

1010
/// Prompt user for confirmation

src/commands/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use serde::{Deserialize, Serialize};
22
use std::path::PathBuf;
33
use std::process::Command;
44

5-
use crate::workspace::WorkspaceContext;
65
use crate::error::{RailError, RailResult};
76
use crate::utils;
7+
use crate::workspace::WorkspaceContext;
88

99
/// Status of a crate
1010
#[derive(Debug, Clone, Serialize, Deserialize)]

src/commands/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::sync::{ConflictStrategy, SyncDirection};
2-
use crate::workspace::WorkspaceContext;
31
use crate::error::{ConfigError, RailError, RailResult};
42
use crate::plan::PlanExecutor;
53
use crate::plan::{Operation, OperationType, Plan};
4+
use crate::sync::{ConflictStrategy, SyncDirection};
65
use crate::utils;
6+
use crate::workspace::WorkspaceContext;
77
use rayon::prelude::*;
88

99
/// Sync command parameters

src/commands/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//! - `--dry-run` to show the plan without executing
1111
//! - Parallel execution via rayon
1212
13-
use crate::workspace::WorkspaceContext;
1413
use crate::error::{RailError, RailResult};
1514
use crate::git::SystemGit;
1615
use crate::graph::AffectedAnalysis;
16+
use crate::workspace::WorkspaceContext;
1717
use std::path::{Path, PathBuf};
1818
use std::process::Command;
1919

src/config.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,6 @@ pub struct ReleaseConfig {
279279
}
280280

281281
impl ReleaseConfig {
282-
/// Check if this release has a split repo configured
283-
pub fn has_split(&self) -> bool {
284-
self.split.is_some()
285-
}
286-
287-
/// Check if this is a new release (never released before)
288-
pub fn is_first_release(&self) -> bool {
289-
self.last_version.is_none() || self.last_sha.is_none()
290-
}
291-
292-
/// Get the last version or default to "0.0.0"
293-
pub fn current_version(&self) -> semver::Version {
294-
self
295-
.last_version
296-
.as_ref()
297-
.and_then(|v| semver::Version::parse(v).ok())
298-
.unwrap_or_else(|| semver::Version::new(0, 0, 0))
299-
}
300-
301282
/// Validate release configuration
302283
pub fn validate(&self, workspace_root: &Path) -> RailResult<()> {
303284
// Validate crate path exists
@@ -410,30 +391,6 @@ impl RailConfig {
410391

411392
Ok(config)
412393
}
413-
414-
/// Save config to rail.toml (default location)
415-
pub fn save(&self, path: &Path) -> RailResult<()> {
416-
let config_path = path.join("rail.toml");
417-
let content = toml_edit::ser::to_string_pretty(self).context("Failed to serialize config to TOML")?;
418-
fs::write(&config_path, content).with_context(|| format!("Failed to write config to {}", config_path.display()))?;
419-
Ok(())
420-
}
421-
422-
/// Check if config exists at the given path
423-
pub fn exists(path: &Path) -> bool {
424-
Self::find_config_path(path).is_some()
425-
}
426-
427-
/// Create a new empty config
428-
pub fn new(workspace_root: PathBuf) -> Self {
429-
Self {
430-
workspace: WorkspaceConfig { root: workspace_root },
431-
security: SecurityConfig::default(),
432-
policy: PolicyConfig::default(),
433-
splits: Vec::new(),
434-
releases: Vec::new(),
435-
}
436-
}
437394
}
438395

439396
impl SplitConfig {

src/error.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ pub enum ExitCode {
1515
User = 1,
1616
/// System error (git, network, I/O)
1717
System = 2,
18-
/// Validation failure (checks failed, SSH, remotes)
19-
Validation = 3,
2018
}
2119

2220
impl ExitCode {
@@ -35,9 +33,6 @@ pub enum RailError {
3533
/// Git operation errors
3634
Git(GitError),
3735

38-
/// Validation errors (SSH, paths, etc.)
39-
Validation(ValidationError),
40-
4136
/// I/O errors
4237
Io(io::Error),
4338

@@ -86,7 +81,6 @@ impl RailError {
8681
match self {
8782
RailError::Config(_) => ExitCode::User,
8883
RailError::Git(_) => ExitCode::System,
89-
RailError::Validation(_) => ExitCode::Validation,
9084
RailError::Io(_) => ExitCode::System,
9185
RailError::Message { .. } => ExitCode::User,
9286
}
@@ -97,7 +91,6 @@ impl RailError {
9791
match self {
9892
RailError::Config(e) => e.help_message(),
9993
RailError::Git(e) => e.help_message(),
100-
RailError::Validation(e) => e.help_message(),
10194
RailError::Message { help, .. } => help.clone(),
10295
_ => None,
10396
}
@@ -109,7 +102,6 @@ impl fmt::Display for RailError {
109102
match self {
110103
RailError::Config(e) => write!(f, "{}", e),
111104
RailError::Git(e) => write!(f, "{}", e),
112-
RailError::Validation(e) => write!(f, "{}", e),
113105
RailError::Io(e) => write!(f, "I/O error: {}", e),
114106
RailError::Message { message, context, .. } => {
115107
write!(f, "{}", message)?;
@@ -315,42 +307,6 @@ impl fmt::Display for GitError {
315307
}
316308
}
317309

318-
/// Validation errors
319-
#[derive(Debug)]
320-
pub enum ValidationError {
321-
/// SSH key not found or invalid
322-
SshKey { message: String },
323-
324-
/// Workspace validation failed
325-
WorkspaceInvalid { reason: String },
326-
}
327-
328-
impl ValidationError {
329-
fn help_message(&self) -> Option<String> {
330-
match self {
331-
ValidationError::SshKey { .. } => {
332-
Some("Create an SSH key with: ssh-keygen -t ed25519 -C \"[email protected]\"".to_string())
333-
}
334-
ValidationError::WorkspaceInvalid { .. } => {
335-
Some("Run `cargo rail doctor` to diagnose workspace issues.".to_string())
336-
}
337-
}
338-
}
339-
}
340-
341-
impl fmt::Display for ValidationError {
342-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
343-
match self {
344-
ValidationError::SshKey { message } => {
345-
write!(f, "SSH key validation failed: {}", message)
346-
}
347-
ValidationError::WorkspaceInvalid { reason } => {
348-
write!(f, "Workspace validation failed: {}", reason)
349-
}
350-
}
351-
}
352-
}
353-
354310
/// Result type alias for cargo-rail
355311
pub type RailResult<T> = Result<T, RailError>;
356312

0 commit comments

Comments
 (0)