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

Function install_hooks

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

Install hooks into .git/hooks/.

()

Source from the content-addressed store, hash-verified

106
107/// Install hooks into .git/hooks/.
108fn install_hooks() -> CliResult<()> {
109 let hooks_dir = find_hooks_dir()?;
110 fs::create_dir_all(&hooks_dir).map_err(|e| CliError::GitError {
111 message: format!("Failed to create hooks directory: {}", e),
112 })?;
113
114 let mut installed = 0;
115 let mut skipped = 0;
116
117 for hook_name in HOOK_NAMES {
118 let hook_path = hooks_dir.join(hook_name);
119 match install_single_hook(&hook_path, hook_name) {
120 Ok(true) => installed += 1,
121 Ok(false) => skipped += 1,
122 Err(e) => {
123 print_warning(&format!("Failed to install {}: {}", hook_name, e));
124 }
125 }
126 }
127
128 if installed > 0 {
129 print_info(&format!(
130 "Installed {} hook(s). {} already present.",
131 installed, skipped
132 ));
133 } else if skipped > 0 {
134 print_info("All hooks already installed.");
135 }
136
137 Ok(())
138}
139
140/// Install a single hook. Returns Ok(true) if newly installed, Ok(false) if already present.
141fn 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