MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / replace_owned_executable

Function replace_owned_executable

atomic-cli/src/commands/git/hooks.rs:502–516  ·  view source on GitHub ↗
(path: &Path, content: &[u8])

Source from the content-addressed store, hash-verified

500}
501
502fn 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)]
519fn set_executable(path: &Path) -> io::Result<()> {

Callers 1

Calls 2

write_new_executableFunction · 0.85
parentMethod · 0.80

Tested by

no test coverage detected