-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #555 from Cloud-Code-AI/549-kaizen-cli-make-easy-s…
…etup-with-ollama 549 kaizen cli make easy setup with ollama
- Loading branch information
Showing
12 changed files
with
242 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
# hooks/prepare-commit-msg | ||
|
||
# Run your CLI command and capture the output | ||
commit_msg=$(kaizen-cli generate-commit-msg) | ||
|
||
# Overwrite the commit message file with the generated message | ||
echo "$commit_msg" > "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
import shutil | ||
import click | ||
|
||
HOOK_TYPES = ["prepare-commit-msg"] | ||
|
||
|
||
@click.group() | ||
def hooks(): | ||
"""Manage git hooks""" | ||
pass | ||
|
||
|
||
@hooks.command() | ||
@click.argument("hook_type", type=click.Choice(HOOK_TYPES)) | ||
def install(hook_type): | ||
"""Install a specific git hook""" | ||
source = os.path.join(os.path.dirname(__file__), "hooks", hook_type) | ||
destination = os.path.join(".git", "hooks", hook_type) | ||
|
||
if not os.path.exists(source): | ||
click.echo(f"Error: Hook script for {hook_type} not found.") | ||
return | ||
|
||
try: | ||
shutil.copy(source, destination) | ||
os.chmod(destination, 0o755) | ||
click.echo(f"{hook_type} hook installed successfully") | ||
except IOError as e: | ||
click.echo(f"Error installing {hook_type} hook: {str(e)}") | ||
|
||
|
||
@hooks.command() | ||
def install_all(): | ||
"""Install all available git hooks""" | ||
for hook_type in HOOK_TYPES: | ||
ctx = click.get_current_context() | ||
ctx.invoke(install, hook_type=hook_type) | ||
|
||
|
||
@hooks.command() | ||
@click.argument("hook_type", type=click.Choice(HOOK_TYPES)) | ||
def uninstall(hook_type): | ||
"""Uninstall a specific git hook""" | ||
hook_path = os.path.join(".git", "hooks", hook_type) | ||
if os.path.exists(hook_path): | ||
os.remove(hook_path) | ||
click.echo(f"{hook_type} hook uninstalled successfully") | ||
else: | ||
click.echo(f"{hook_type} hook not found") | ||
|
||
|
||
@hooks.command() | ||
def uninstall_all(): | ||
"""Uninstall all git hooks""" | ||
for hook_type in HOOK_TYPES: | ||
ctx = click.get_current_context() | ||
ctx.invoke(uninstall, hook_type=hook_type) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.