Fix CI/CD: Add Gitea Actions workflow and fix linting issues

This commit is contained in:
Developer
2026-02-05 09:02:49 +00:00
commit d8325c4be2
111 changed files with 19657 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
from .hooks import check_hook_installed, install_pre_commit_hook
__all__ = ["check_hook_installed", "install_pre_commit_hook"]

View File

@@ -0,0 +1,69 @@
from pathlib import Path
def get_hook_script() -> str:
return """#!/bin/bash
# Local AI Commit Reviewer - Pre-commit Hook
# Automatically reviews staged changes before committing
set -e
# Allow bypass with --no-verify
if [ "$1" = "--no-verify" ]; then
exit 0
fi
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Change to repository root
cd "$SCRIPT_DIR/../.."
# Run the AI commit reviewer
python -m aicr review --hook --strictness balanced || exit 1
"""
def install_pre_commit_hook(
repo_path: Path,
content: str | None = None,
force: bool = False
) -> bool:
hooks_dir = repo_path / ".git" / "hooks"
hooks_dir.mkdir(parents=True, exist_ok=True)
hook_path = hooks_dir / "pre-commit"
if hook_path.exists() and not force:
return False
if content is None:
content = get_hook_script()
try:
hook_path.write_text(content)
hook_path.chmod(0o755)
return True
except OSError:
return False
def check_hook_installed(repo_path: Path) -> bool:
hook_path = repo_path / ".git" / "hooks" / "pre-commit"
if not hook_path.exists():
return False
content = hook_path.read_text()
return "aicr" in content or "local-ai-commit-reviewer" in content
def uninstall_hook(repo_path: Path) -> bool:
hook_path = repo_path / ".git" / "hooks" / "pre-commit"
if not hook_path.exists():
return True
try:
hook_path.unlink()
return True
except OSError:
return False