(path: &Path, content: &[u8])
| 500 | } |
| 501 | |
| 502 | fn replace_owned_executable(path: &Path, content: &[u8]) -> io::Result<()> { |
| 503 | let parent = path.parent().ok_or_else(|| { |
| 504 | io::Error::new(ErrorKind::InvalidInput, "hook path has no parent directory") |
| 505 | })?; |
| 506 | let temporary = parent.join(format!(".atomic-post-checkout-{}.tmp", Uuid::new_v4())); |
| 507 | let result = (|| { |
| 508 | write_new_executable(&temporary, content)?; |
| 509 | fs::rename(&temporary, path)?; |
| 510 | Ok(()) |
| 511 | })(); |
| 512 | if result.is_err() { |
| 513 | let _ = fs::remove_file(&temporary); |
| 514 | } |
| 515 | result |
| 516 | } |
| 517 | |
| 518 | #[cfg(unix)] |
| 519 | fn set_executable(path: &Path) -> io::Result<()> { |
no test coverage detected