diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-01 14:31:32 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-01 15:22:38 +0000 |
| commit | d2ac69816567f092fe0d4661723bc43778cb481b (patch) | |
| tree | e8b51b61a6a7b0ab1a214adebe4e237143b01f0b /src/git/subprocess.rs | |
| parent | 7a78815e29b01c83f3d0ec195ba717a2eba8cd37 (diff) | |
fix cargo clippy and fmt warnings
Diffstat (limited to 'src/git/subprocess.rs')
| -rw-r--r-- | src/git/subprocess.rs | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/git/subprocess.rs b/src/git/subprocess.rs index c95bce5..2d9a981 100644 --- a/src/git/subprocess.rs +++ b/src/git/subprocess.rs | |||
| @@ -28,9 +28,9 @@ impl GitSubprocess { | |||
| 28 | advertise: bool, | 28 | advertise: bool, |
| 29 | ) -> std::io::Result<Self> { | 29 | ) -> std::io::Result<Self> { |
| 30 | let repo_path = repo_path.as_ref(); | 30 | let repo_path = repo_path.as_ref(); |
| 31 | 31 | ||
| 32 | let mut cmd = Command::new("git"); | 32 | let mut cmd = Command::new("git"); |
| 33 | 33 | ||
| 34 | // GRASP-01 requirement: MUST include `allow-reachable-sha1-in-want` and | 34 | // GRASP-01 requirement: MUST include `allow-reachable-sha1-in-want` and |
| 35 | // `allow-tip-sha1-in-want` in advertisement and serve available oids. | 35 | // `allow-tip-sha1-in-want` in advertisement and serve available oids. |
| 36 | // These config options must be passed before the command name. | 36 | // These config options must be passed before the command name. |
| @@ -38,22 +38,22 @@ impl GitSubprocess { | |||
| 38 | cmd.arg("uploadpack.allowReachableSHA1InWant=true"); | 38 | cmd.arg("uploadpack.allowReachableSHA1InWant=true"); |
| 39 | cmd.arg("-c"); | 39 | cmd.arg("-c"); |
| 40 | cmd.arg("uploadpack.allowTipSHA1InWant=true"); | 40 | cmd.arg("uploadpack.allowTipSHA1InWant=true"); |
| 41 | 41 | ||
| 42 | cmd.arg(service.command_name()); | 42 | cmd.arg(service.command_name()); |
| 43 | 43 | ||
| 44 | if advertise { | 44 | if advertise { |
| 45 | cmd.arg("--advertise-refs"); | 45 | cmd.arg("--advertise-refs"); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | cmd.arg("--stateless-rpc"); | 48 | cmd.arg("--stateless-rpc"); |
| 49 | cmd.arg(repo_path); | 49 | cmd.arg(repo_path); |
| 50 | 50 | ||
| 51 | cmd.stdin(Stdio::piped()); | 51 | cmd.stdin(Stdio::piped()); |
| 52 | cmd.stdout(Stdio::piped()); | 52 | cmd.stdout(Stdio::piped()); |
| 53 | cmd.stderr(Stdio::piped()); | 53 | cmd.stderr(Stdio::piped()); |
| 54 | 54 | ||
| 55 | let child = cmd.spawn()?; | 55 | let child = cmd.spawn()?; |
| 56 | 56 | ||
| 57 | Ok(Self { child }) | 57 | Ok(Self { child }) |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -101,8 +101,8 @@ impl GitSubprocess { | |||
| 101 | #[cfg(test)] | 101 | #[cfg(test)] |
| 102 | mod tests { | 102 | mod tests { |
| 103 | use super::*; | 103 | use super::*; |
| 104 | use tempfile::TempDir; | ||
| 105 | use std::process::Command as StdCommand; | 104 | use std::process::Command as StdCommand; |
| 105 | use tempfile::TempDir; | ||
| 106 | 106 | ||
| 107 | fn create_bare_repo() -> TempDir { | 107 | fn create_bare_repo() -> TempDir { |
| 108 | let dir = TempDir::new().unwrap(); | 108 | let dir = TempDir::new().unwrap(); |
| @@ -118,11 +118,8 @@ mod tests { | |||
| 118 | #[tokio::test] | 118 | #[tokio::test] |
| 119 | async fn test_spawn_upload_pack_advertise() { | 119 | async fn test_spawn_upload_pack_advertise() { |
| 120 | let repo = create_bare_repo(); | 120 | let repo = create_bare_repo(); |
| 121 | let mut proc = GitSubprocess::spawn( | 121 | let mut proc = GitSubprocess::spawn(GitService::UploadPack, repo.path(), true) |
| 122 | GitService::UploadPack, | 122 | .expect("Failed to spawn git"); |
| 123 | repo.path(), | ||
| 124 | true, | ||
| 125 | ).expect("Failed to spawn git"); | ||
| 126 | 123 | ||
| 127 | // Should have spawned successfully | 124 | // Should have spawned successfully |
| 128 | assert!(proc.stdout().is_some()); | 125 | assert!(proc.stdout().is_some()); |
| @@ -135,15 +132,12 @@ mod tests { | |||
| 135 | #[tokio::test] | 132 | #[tokio::test] |
| 136 | async fn test_spawn_receive_pack() { | 133 | async fn test_spawn_receive_pack() { |
| 137 | let repo = create_bare_repo(); | 134 | let repo = create_bare_repo(); |
| 138 | let mut proc = GitSubprocess::spawn( | 135 | let mut proc = GitSubprocess::spawn(GitService::ReceivePack, repo.path(), false) |
| 139 | GitService::ReceivePack, | 136 | .expect("Failed to spawn git"); |
| 140 | repo.path(), | ||
| 141 | false, | ||
| 142 | ).expect("Failed to spawn git"); | ||
| 143 | 137 | ||
| 144 | assert!(proc.stdout().is_some()); | 138 | assert!(proc.stdout().is_some()); |
| 145 | assert!(proc.stdin().is_some()); | 139 | assert!(proc.stdin().is_some()); |
| 146 | 140 | ||
| 147 | let _ = proc.kill().await; | 141 | let _ = proc.kill().await; |
| 148 | } | 142 | } |
| 149 | } \ No newline at end of file | 143 | } |