Skip to content

Commit

Permalink
fix: preserve original path in lock
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Apr 10, 2023
1 parent 77b2672 commit f07eab6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions crates/depit/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ impl Entry {
/// # Errors
///
/// Returns an error if [`Self::digest`] of `path` fails
pub async fn from_path(path: PathBuf) -> anyhow::Result<Self> {
let digest = Self::digest(&path)
pub async fn from_path(src: PathBuf, dst: impl AsRef<Path>) -> anyhow::Result<Self> {
let digest = Self::digest(dst)
.await
.context("failed to compute digest")?;
Ok(Self::new(EntrySource::Path(path), digest))
Ok(Self::new(EntrySource::Path(src), digest))
}

/// Compute the digest of an entry from path
Expand Down
7 changes: 4 additions & 3 deletions crates/depit/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ impl Entry {

match self {
Self::Path(path) => {
let path = at.map(|at| at.as_ref().join(&path)).unwrap_or(path);
copy_wits(&path, out).await?;
LockEntry::from_path(path).await
let dst = at.map(|at| at.as_ref().join(&path));
copy_wits(&dst.as_ref().unwrap_or(&path), out).await?;
let digest = LockEntry::digest(dst.as_ref().unwrap_or(&path)).await?;
Ok(LockEntry::new(LockEntrySource::Path(path), digest))
}
Self::Url {
url,
Expand Down
12 changes: 6 additions & 6 deletions tests/build/subcrate/wit/deps.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[build]
path = "wit/../../wit"
path = "../../wit"
sha256 = "ec29ec48fdb09b2efcb989bd821cc5c1aef318b41a1dd9908534c667591de680"
sha512 = "6317d43cbf66f99c7052c24d4cc2fb308b001acfe88964f3dcb6b976c77bc83cda127f8c671c71eb19f379f7fc37cb039eccae3e53e77ae5ca883d991d852d94"

[http]
path = "wit/../../wit/deps/http"
path = "../../wit/deps/http"
sha256 = "1667921c63364722b0d23eb69023ede0cdace86ee9b4c6f7c4286b3a2dd8d635"
sha512 = "9b2f225411d347d3e99276359d3ad98475e9fbee4b3fad0169060dc648a5efa3584a6a1db990607a4971c7e3c0026dc65f8e48fe2824f9553840bb46f3b389ae"

[io]
path = "wit/../../wit/deps/io"
path = "../../wit/deps/io"
sha256 = "50e907cde3a0b49b2358c564a10db26e3585a5466029baaecb00424dccea77a1"
sha512 = "096953066bc1e690b90e01d0a8ed92650052184173df8dac1e24d2a277a6f864a078eca0d555fa2de0b38be1ba8ed25db7949a396f60c9a35def7ea956a66ff1"

[logging]
path = "wit/../../wit/deps/logging"
path = "../../wit/deps/logging"
sha256 = "f378a2b6a36af096528ec5e7031da474990cecaec1949c663befc5066d719f6f"
sha512 = "ba09307b12f5428c3058d878001c9fb15df21933c6203328f785d5009a4fc0cf304950271590d4146305a2d8b8988595f396d955961168cb6bfa7ea9af1cc362"

[poll]
path = "wit/../../wit/deps/poll"
path = "../../wit/deps/poll"
sha256 = "065422b0ea6ccb2a9facc6b87b902eef110c53d76fc31f341a6bc8d0b0285b6a"
sha512 = "19a55cd3072a19ae6a1774723a4962e7a155a5ce89a27175e8c76020efb4d00bc92ebb78427d92bcb8effd4f0d03ebf0a0daa747ecd981b8d31d5abc2ad86423"

[random]
path = "wit/../../wit/deps/random"
path = "../../wit/deps/random"
sha256 = "79b6417bb1ab3c82c241c56021e717f258e2a0b3ab94db93907ca11d7f92ed66"
sha512 = "1e657ac56420e65bde75eabea920a605a0ff4adc6f2ba8b7cf1c37a603710449bc1a29568dda2b61c04ae9889d2b1a82b9935d4b9d573eb48a83e0ecf9cad591"

0 comments on commit f07eab6

Please sign in to comment.