Skip to content

Commit 77355f9

Browse files
committed
cargo-rail: fixing the junit paths/config; fixing the Windows path issues still.
1 parent c949114 commit 77355f9

File tree

11 files changed

+44
-37
lines changed

11 files changed

+44
-37
lines changed

.config/nextest.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ retries = { backoff = "exponential", count = 2, delay = "1s", jitter = true }
1818

1919
[profile.commit.junit]
2020
path = "junit.xml"
21+
report-name = "cargo-rail-tests"
22+
store-success-output = false
23+
store-failure-output = true

.github/workflows/commit.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,22 @@ jobs:
8181
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
8282
with:
8383
name: junit-report-${{ matrix.target.name }}
84-
path: junit.xml
84+
path: target/nextest/commit/junit.xml
8585
retention-days: 7
8686
if-no-files-found: ignore
8787

8888
- name: Publish Test Report
8989
if: always()
9090
uses: mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6 # v6.0.1
9191
with:
92-
report_paths: 'junit.xml'
92+
report_paths: 'target/nextest/commit/junit.xml'
9393
check_name: 'Test Results (${{ matrix.target.name }})'
9494
detailed_summary: true
9595
include_passed: false
9696
fail_on_failure: true
97+
require_tests: true
98+
annotate_only: false
99+
summary: true
97100

98101
- name: Upload Nextest Results (on failure)
99102
if: failure()

src/checks/remotes.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::trait_def::{Check, CheckContext, CheckResult};
44
use crate::core::config::RailConfig;
55
use crate::core::error::RailResult;
66
use crate::ui::progress::FileProgress;
7+
use crate::utils;
78
use std::process::Command;
89

910
/// Check that validates remote repository accessibility
@@ -137,7 +138,7 @@ fn is_valid_remote_url(url: &str) -> bool {
137138
}
138139

139140
// Local path (absolute or relative)
140-
if url.starts_with('/') || url.starts_with("./") || url.starts_with("../") {
141+
if utils::is_local_path(url) {
141142
return true;
142143
}
143144

@@ -147,7 +148,7 @@ fn is_valid_remote_url(url: &str) -> bool {
147148
/// Test if we can access a remote repository
148149
fn test_remote_access(url: &str) -> RailResult<bool> {
149150
// For local paths, just check if directory exists
150-
if url.starts_with('/') || url.starts_with("./") || url.starts_with("../") {
151+
if utils::is_local_path(url) {
151152
let path = std::path::Path::new(url);
152153
return Ok(path.exists());
153154
}

src/commands/mappings.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::core::config::RailConfig;
66
use crate::core::error::{ConfigError, RailError, RailResult};
77
use crate::core::mapping::MappingStore;
88
use crate::ui::progress::FileProgress;
9+
use crate::utils;
910

1011
/// A single SHA mapping
1112
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -176,10 +177,7 @@ fn get_target_path(
176177
current_dir: &std::path::Path,
177178
split_config: &crate::core::config::SplitConfig,
178179
) -> Option<std::path::PathBuf> {
179-
let target_repo_path = if split_config.remote.starts_with('/')
180-
|| split_config.remote.starts_with("./")
181-
|| split_config.remote.starts_with("../")
182-
{
180+
let target_repo_path = if utils::is_local_path(&split_config.remote) {
183181
std::path::PathBuf::from(&split_config.remote)
184182
} else {
185183
let remote_name = split_config

src/commands/split.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ pub fn run_split(
129129
let crate_paths = split_config.get_paths().into_iter().cloned().collect::<Vec<_>>();
130130

131131
// Determine target repo path
132-
let target_repo_path = if split_config.remote.starts_with('/')
133-
|| split_config.remote.starts_with("./")
134-
|| split_config.remote.starts_with("../")
135-
{
132+
let target_repo_path = if utils::is_local_path(&split_config.remote) {
136133
std::path::PathBuf::from(&split_config.remote)
137134
} else {
138135
let remote_name = split_config

src/commands/status.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::process::Command;
55

66
use crate::core::config::RailConfig;
77
use crate::core::error::{ConfigError, RailError, RailResult};
8+
use crate::utils;
89

910
/// Status of a crate
1011
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -71,10 +72,7 @@ pub fn run_status(json: bool) -> RailResult<()> {
7172
let mut statuses = Vec::new();
7273

7374
for split_config in &config.splits {
74-
let target_repo_path = if split_config.remote.starts_with('/')
75-
|| split_config.remote.starts_with("./")
76-
|| split_config.remote.starts_with("../")
77-
{
75+
let target_repo_path = if utils::is_local_path(&split_config.remote) {
7876
std::path::PathBuf::from(&split_config.remote)
7977
} else {
8078
let remote_name = split_config

src/commands/sync.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ fn run_sync_impl(params: SyncParams) -> RailResult<()> {
187187
let crate_paths = split_config.get_paths().into_iter().cloned().collect::<Vec<_>>();
188188

189189
// Determine target repo path
190-
let target_repo_path = if split_config.remote.starts_with('/')
191-
|| split_config.remote.starts_with("./")
192-
|| split_config.remote.starts_with("../")
193-
{
190+
let target_repo_path = if utils::is_local_path(&split_config.remote) {
194191
std::path::PathBuf::from(&split_config.remote)
195192
} else {
196193
let remote_name = split_config

src/utils.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ pub fn is_local_path(path: &str) -> bool {
3535
return true;
3636
}
3737

38-
// Check for absolute paths (works on Unix, and Windows on Windows)
38+
// Check for Unix absolute paths (/path/to/repo)
39+
// Important: Check this BEFORE is_absolute() because on Windows,
40+
// Path::is_absolute() returns false for Unix-style paths
41+
if path.starts_with('/') {
42+
// Make sure it's not part of a URL pattern
43+
if !path.contains("://") && !path.contains('@') {
44+
return true;
45+
}
46+
}
47+
48+
// Check for absolute paths (fallback for platform-specific cases)
3949
if p.is_absolute() {
4050
return true;
4151
}

tests/integration/test_split.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn test_split_creates_repo_with_history() -> Result<()> {
2121
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
2222

2323
// Run split with remote override
24-
let split_dir = workspace.path.join("split-repos/my-crate-split");
24+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
2525
run_cargo_rail(
2626
&workspace.path,
2727
&[
@@ -74,7 +74,7 @@ fn test_split_transforms_cargo_toml() -> Result<()> {
7474

7575
// Initialize and split app-crate with remote override
7676
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
77-
let split_dir = workspace.path.join("split-repos/app-crate-split");
77+
let split_dir = workspace.path.join("split-repos").join("app-crate-split");
7878
run_cargo_rail(
7979
&workspace.path,
8080
&[
@@ -124,7 +124,7 @@ fn test_split_filters_commits() -> Result<()> {
124124

125125
// Initialize and split crate-a with remote override
126126
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
127-
let split_dir = workspace.path.join("split-repos/crate-a-split");
127+
let split_dir = workspace.path.join("split-repos").join("crate-a-split");
128128
run_cargo_rail(
129129
&workspace.path,
130130
&[
@@ -169,7 +169,7 @@ fn test_split_copies_auxiliary_files() -> Result<()> {
169169

170170
// Initialize and split with remote override
171171
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
172-
let split_dir = workspace.path.join("split-repos/my-crate-split");
172+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
173173
run_cargo_rail(
174174
&workspace.path,
175175
&[

tests/integration/test_sync.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn test_sync_mono_to_remote() -> Result<()> {
1212
workspace.commit("Add my-crate")?;
1313

1414
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
15-
let split_dir = workspace.path.join("split-repos/my-crate-split");
15+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
1616
run_cargo_rail(
1717
&workspace.path,
1818
&[
@@ -65,7 +65,7 @@ fn test_sync_remote_to_mono() -> Result<()> {
6565
workspace.commit("Add my-crate")?;
6666

6767
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
68-
let split_dir = workspace.path.join("split-repos/my-crate-split");
68+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
6969
run_cargo_rail(
7070
&workspace.path,
7171
&[
@@ -121,7 +121,7 @@ fn test_sync_bidirectional() -> Result<()> {
121121
workspace.commit("Add my-crate")?;
122122

123123
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
124-
let split_dir = workspace.path.join("split-repos/my-crate-split");
124+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
125125
run_cargo_rail(
126126
&workspace.path,
127127
&[
@@ -190,7 +190,7 @@ fn test_sync_deduplicates_commits() -> Result<()> {
190190
workspace.commit("Add my-crate")?;
191191

192192
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
193-
let split_dir = workspace.path.join("split-repos/my-crate-split");
193+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
194194
run_cargo_rail(
195195
&workspace.path,
196196
&[
@@ -254,7 +254,7 @@ fn test_conflict_resolution_ours_strategy() -> Result<()> {
254254
workspace.commit("Add my-crate")?;
255255

256256
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
257-
let split_dir = workspace.path.join("split-repos/my-crate-split");
257+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
258258

259259
run_cargo_rail(
260260
&workspace.path,
@@ -334,7 +334,7 @@ fn test_conflict_resolution_theirs_strategy() -> Result<()> {
334334
workspace.commit("Add my-crate")?;
335335

336336
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
337-
let split_dir = workspace.path.join("split-repos/my-crate-split");
337+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
338338

339339
run_cargo_rail(
340340
&workspace.path,
@@ -410,7 +410,7 @@ fn test_conflict_resolution_manual_strategy() -> Result<()> {
410410
workspace.commit("Add my-crate")?;
411411

412412
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
413-
let split_dir = workspace.path.join("split-repos/my-crate-split");
413+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
414414

415415
run_cargo_rail(
416416
&workspace.path,
@@ -487,7 +487,7 @@ fn test_conflict_resolution_union_strategy() -> Result<()> {
487487
workspace.commit("Add my-crate")?;
488488

489489
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
490-
let split_dir = workspace.path.join("split-repos/my-crate-split");
490+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
491491

492492
run_cargo_rail(
493493
&workspace.path,
@@ -567,7 +567,7 @@ fn test_no_conflict_with_non_overlapping_changes() -> Result<()> {
567567
workspace.commit("Add my-crate")?;
568568

569569
run_cargo_rail(&workspace.path, &["rail", "init", "--all"])?;
570-
let split_dir = workspace.path.join("split-repos/my-crate-split");
570+
let split_dir = workspace.path.join("split-repos").join("my-crate-split");
571571
run_cargo_rail(
572572
&workspace.path,
573573
&[

0 commit comments

Comments
 (0)