Skip to content

Commit

Permalink
: don't panic in relative_path (#36)
Browse files Browse the repository at this point in the history
Summary:

if in `relative_path` we find `to` and `from` are in different file systems, don't panic but instead just return `to` unmodified. testing indicates that `reindeer buckify` continues to work as normal with that choice in this case (and so we can avoid needing `CARGO_HOME` workarounds).

Differential Revision: D52989646
  • Loading branch information
Shayne Fletcher committed Jan 23, 2024
1 parent 09c3167 commit 6f8c3d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
os: [ubuntu, macos, windows]
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: echo CARGO_HOME=$GITHUB_WORKSPACE/.cargo >> $GITHUB_ENV
shell: bash
# - uses: Swatinem/rust-cache@v2
- run: cargo build --locked
- run: cargo test
- run: |-
Expand Down
2 changes: 1 addition & 1 deletion example/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ set -e
# typically commit these fixups and the generated third-party/BUCK in the same
# commit as above.

../target/debug/reindeer --third-party-dir third-party buckify
RUST_LOG="debug" ../target/debug/reindeer --third-party-dir third-party buckify
25 changes: 24 additions & 1 deletion src/buckify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,30 @@ pub fn relative_path(mut base: &Path, to: &Path) -> PathBuf {
res.display()
);
res.push("..");
base = base.parent().expect("root dir not prefix of other?");
base.parent().expect("root not prefix of other?")
/*
match base.parent() {
Some(parent) => base = parent,
None => {
// Here, `to` and `base` do not share a common
// ancestor.
// Example:
// - `to` = 'C:\Users\runneradmin\.cargo\...001f\anyhow-1.0.79\build.rs'
// - `base` = 'D:\a\reindeer\reindeer\shim\third-party\rust'
// In this case return `to` "as-is" (i.e. without any
// modification)`. `reindeer buckify` seems to work
// with this choice.
log::debug!(
"relative_path: no common ancestor. returning to={}",
to.display(),
);
return to.to_path_buf();
}
}
*/
}

res.join(
Expand Down

0 comments on commit 6f8c3d3

Please sign in to comment.