Loading tools/cargo-check-external-types/Cargo.lock +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "cargo-check-external-types" version = "0.1.0" version = "0.1.1" dependencies = [ "anyhow", "cargo_metadata", Loading tools/smithy-rs-tool-common/Cargo.toml +3 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,6 @@ serde_json = "1" tokio = { version = "1", features = ["rt", "macros"], optional = true } toml = { version = "0.5.8", features = ["preserve_order"] } tracing = "0.1" [dev-dependencies] tempfile = "3.3.0" tools/smithy-rs-tool-common/src/git.rs +25 −2 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ pub struct GitCLI { impl GitCLI { pub fn new(repo_path: &Path) -> Result<Self> { if !repo_path.join(".git").is_dir() { if !repo_path.join(".git").exists() { bail!("{:?} is not a git repository", repo_path); } Ok(Self { Loading Loading @@ -429,7 +429,8 @@ fn log_command(command: Command) -> Command { #[cfg(test)] mod tests { use super::*; use std::env; use std::{env, fs}; use tempfile::TempDir; fn bin_path(script: &'static str) -> PathBuf { env::current_dir() Loading Loading @@ -616,4 +617,26 @@ mod tests { .squash_merge("some-dev", "some-email@example.com", "test-branch-name") .expect("successful invocation"); } #[test] fn repository_root_check() { let tmp_dir = TempDir::new().unwrap(); GitCLI::new(tmp_dir.path()) .err() .expect("repository root check should fail"); fs::create_dir(tmp_dir.path().join(".git")).unwrap(); GitCLI::new(tmp_dir.path()).expect("repository root check should succeed"); } #[test] fn repository_root_check_works_for_git_submodules() { let tmp_dir = TempDir::new().unwrap(); GitCLI::new(tmp_dir.path()) .err() .expect("repository root check should fail"); fs::write(tmp_dir.path().join(".git"), "gitdir: some/fake/path").unwrap(); GitCLI::new(tmp_dir.path()).expect("repository root check should succeed"); } } Loading
tools/cargo-check-external-types/Cargo.lock +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "cargo-check-external-types" version = "0.1.0" version = "0.1.1" dependencies = [ "anyhow", "cargo_metadata", Loading
tools/smithy-rs-tool-common/Cargo.toml +3 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,6 @@ serde_json = "1" tokio = { version = "1", features = ["rt", "macros"], optional = true } toml = { version = "0.5.8", features = ["preserve_order"] } tracing = "0.1" [dev-dependencies] tempfile = "3.3.0"
tools/smithy-rs-tool-common/src/git.rs +25 −2 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ pub struct GitCLI { impl GitCLI { pub fn new(repo_path: &Path) -> Result<Self> { if !repo_path.join(".git").is_dir() { if !repo_path.join(".git").exists() { bail!("{:?} is not a git repository", repo_path); } Ok(Self { Loading Loading @@ -429,7 +429,8 @@ fn log_command(command: Command) -> Command { #[cfg(test)] mod tests { use super::*; use std::env; use std::{env, fs}; use tempfile::TempDir; fn bin_path(script: &'static str) -> PathBuf { env::current_dir() Loading Loading @@ -616,4 +617,26 @@ mod tests { .squash_merge("some-dev", "some-email@example.com", "test-branch-name") .expect("successful invocation"); } #[test] fn repository_root_check() { let tmp_dir = TempDir::new().unwrap(); GitCLI::new(tmp_dir.path()) .err() .expect("repository root check should fail"); fs::create_dir(tmp_dir.path().join(".git")).unwrap(); GitCLI::new(tmp_dir.path()).expect("repository root check should succeed"); } #[test] fn repository_root_check_works_for_git_submodules() { let tmp_dir = TempDir::new().unwrap(); GitCLI::new(tmp_dir.path()) .err() .expect("repository root check should fail"); fs::write(tmp_dir.path().join(".git"), "gitdir: some/fake/path").unwrap(); GitCLI::new(tmp_dir.path()).expect("repository root check should succeed"); } }