diff --git a/Cargo.lock b/Cargo.lock index 8a2b193..115e0e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" @@ -152,7 +152,7 @@ dependencies = [ "petgraph", "semver", "serde", - "toml", + "toml 0.7.8", "url", ] @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "clru" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" [[package]] name = "cmd_lib" @@ -1202,9 +1202,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libgit2-sys" @@ -1340,9 +1340,9 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -1654,18 +1654,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -1862,7 +1862,19 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.12", ] [[package]] @@ -1884,7 +1896,20 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.7", ] [[package]] @@ -2268,6 +2293,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +dependencies = [ + "memchr", +] + [[package]] name = "wsx" version = "0.1.0" @@ -2282,7 +2316,7 @@ dependencies = [ "regex", "serde", "sha2", - "toml", + "toml 0.8.12", "tracing", "tracing-subscriber", "walkdir", @@ -2290,18 +2324,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" dependencies = [ "proc-macro2", "quote", diff --git a/src/lib.rs b/src/lib.rs index 2e4a7f9..509667b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,7 +87,10 @@ fn find_git_dir(path: &str) -> Result> { Ok(found) } -/// Represents a workspace which is just a collection of repositories. +/// A `Workspace` is filesystem directory containing git repositories checked out +/// from one or more remotes. Each repository's path matches the remote's path, +/// for example: +/// /github.com/cilki/wsx #[derive(Debug, Serialize, Deserialize)] pub struct Workspace { /// A user-friendly name for the workspace like "personal" or "work" @@ -121,23 +124,24 @@ pub struct Provider { pub name: String, } -/// Represents a workspace cache which is just a collection of bare repositories. +/// Caches repositories that are dropped from a `Workspace` in a separate directory. +/// Entries in this cache are bare repositories for space efficiency. #[derive(Debug, Serialize, Deserialize)] pub struct Cache { - pub cache: String, + pub path: String, } impl Cache { /// Move the given repository into the cache. pub fn cache(&self, repo_path: String) -> Result<()> { // Make sure the cache directory exists first - std::fs::create_dir_all(&self.cache)?; + std::fs::create_dir_all(&self.path)?; let source = format!("{}/.git", repo_path); let dest = self.compute_cache_key(&repo_path); run_fun!(git -C $source config core.bare true)?; - debug!("Caching '{}' -> '{}'", source, dest); + debug!(source = %source, dest = %dest, "Caching repository"); // Clear the cache entry if it exists std::fs::remove_dir_all(&dest).ok(); @@ -162,7 +166,7 @@ impl Cache { fn compute_cache_key(&self, path: &str) -> String { format!( "{}/{:x}", - self.cache, + self.path, Sha512::new().chain_update(path).finalize() ) }