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

Function install_hooks

atomic-cli/src/commands/git/hooks.rs:92–122  ·  view source on GitHub ↗

Install hooks into .git/hooks/.

()

Source from the content-addressed store, hash-verified

90
91/// Install hooks into .git/hooks/.
92fn install_hooks() -> CliResult<()> {
93 let hooks_dir = find_hooks_dir()?;
94 fs::create_dir_all(&hooks_dir).map_err(|e| CliError::GitError {
95 message: format!("Failed to create hooks directory: {}", e),
96 })?;
97
98 let mut installed = 0;
99 let mut skipped = 0;
100
101 for hook_name in HOOK_NAMES {
102 let hook_path = hooks_dir.join(hook_name);
103 match install_single_hook(&hook_path, hook_name) {
104 Ok(true) => installed += 1,
105 Ok(false) => skipped += 1,
106 Err(e) => {
107 print_warning(&format!("Failed to install {}: {}", hook_name, e));
108 }
109 }
110 }
111
112 if installed > 0 {
113 print_info(&format!(
114 "Installed {} hook(s). {} already present.",
115 installed, skipped
116 ));
117 } else if skipped > 0 {
118 print_info("All hooks already installed.");
119 }
120
121 Ok(())
122}
123
124/// Install a single hook. Returns Ok(true) if newly installed, Ok(false) if already present.
125fn install_single_hook(path: &Path, _name: &str) -> Result<bool, std::io::Error> {

Callers 1

runMethod · 0.85

Calls 4

find_hooks_dirFunction · 0.85
install_single_hookFunction · 0.85
print_warningFunction · 0.85
print_infoFunction · 0.85

Tested by

no test coverage detected