Skip to content

Commit 542c033

Browse files
tamirdjmgao
authored andcommitted
Add mac,windows to CI
1 parent d7069d0 commit 542c033

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ on:
1010

1111
jobs:
1212
build:
13-
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os:
17+
- macos-latest
18+
- ubuntu-latest
19+
- windows-latest
20+
21+
runs-on: ${{ matrix.os }}
1422

1523
steps:
1624
- uses: actions/checkout@v4
@@ -20,6 +28,7 @@ jobs:
2028
with:
2129
tool: cargo-hack,taplo-cli
2230
- run: taplo fmt --check --diff
31+
if: ${{ matrix.os != 'windows-latest' }} # https://github.com/tamasfe/taplo/issues/766
2332
- run: cargo fmt --all -- --check
2433
- run: cargo hack clippy --all-targets --feature-powerset --workspace -- --deny warnings
2534
- run: cargo hack test --all-targets --feature-powerset --workspace

src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ use std::ffi::OsString;
3030
use std::fmt::Write as _;
3131
use std::io::IsTerminal as _;
3232
use std::io::Write as _;
33-
#[cfg(unix)]
34-
use std::os::unix::fs::MetadataExt as _;
3533
use std::path::{Path, PathBuf};
3634

3735
use anyhow::{Context as _, Error};
@@ -691,6 +689,19 @@ fn cmd_status(
691689
Ok(status)
692690
}
693691

692+
#[cfg(unix)]
693+
fn is_same_device(left: &std::fs::Metadata, right: &std::fs::Metadata) -> bool {
694+
use std::os::unix::fs::MetadataExt as _;
695+
left.dev() == right.dev()
696+
}
697+
698+
#[cfg(windows)]
699+
fn is_same_device(left: &std::fs::Metadata, right: &std::fs::Metadata) -> bool {
700+
// TODO(https://github.com/rust-lang/rust/issues/63010): Use std::os::windows::fs::MetadataExt::volume_serial_number.
701+
let _ = (left, right);
702+
false
703+
}
704+
694705
fn cmd_import(config: &Config, pool: &mut Pool, target_path: Option<PathBuf>, copy: bool) -> Result<i32, Error> {
695706
let target_path = target_path.unwrap_or(PathBuf::from("."));
696707
let target_metadata = std::fs::metadata(&target_path)?;
@@ -717,7 +728,7 @@ fn cmd_import(config: &Config, pool: &mut Pool, target_path: Option<PathBuf>, co
717728
std::fs::create_dir_all(&depot.path).context("failed to create depot directory")?;
718729
let depot_metadata = std::fs::metadata(&depot.path)?;
719730

720-
if !copy && depot_metadata.dev() != target_metadata.dev() {
731+
if !copy && !is_same_device(&depot_metadata, &target_metadata) {
721732
bail!(
722733
"Depot ({:?}) and target ({:?}) appear to be on different filesystems.\n \
723734
Either move the depot to the same filesystem, or use --copy to copy instead.",

src/tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use std::fmt;
1919
use std::io::Write;
2020
use std::iter::FromIterator as _;
2121
use std::ops::Deref as _;
22-
#[cfg(unix)]
23-
use std::os::unix::fs::PermissionsExt as _;
2422
use std::path::{Path, PathBuf};
2523

2624
use anyhow::{Context as _, Error};
@@ -1044,6 +1042,8 @@ impl Tree {
10441042
// that prohibits it.
10451043
#[cfg(unix)]
10461044
{
1045+
use std::os::unix::fs::PermissionsExt as _;
1046+
10471047
let mut permissions = file.metadata()?.permissions();
10481048
permissions.set_mode(0o700);
10491049
file.set_permissions(permissions)?;

0 commit comments

Comments
 (0)