-
Notifications
You must be signed in to change notification settings - Fork 0
Add integration with git hooks #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: JayDoubleu <40270505+JayDoubleu@users.noreply.github.com>
|
Can you implement some tests for this new functionality ? |
Co-authored-by: JayDoubleu <40270505+JayDoubleu@users.noreply.github.com>
I've implemented comprehensive tests for the git hooks functionality in commit e4a9814. The tests cover both the Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
can you run the tests in docker for me ? |
Co-authored-by: JayDoubleu <40270505+JayDoubleu@users.noreply.github.com>
I've added Docker support for running tests in commit 9cc4670. The implementation includes:
Documentation has been added to DEVELOPMENT.md with examples of how to use the Docker testing environment. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds automatic AI-powered commit message generation by integrating with Git's prepare-commit-msg hook.
- Added new methods in GitRepo for installing and uninstalling the hook, including a backup mechanism.
- Introduced CLI commands for managing hooks and updated tests and documentation to support the new feature.
- Updated Docker scripts and configuration to run the new hooks tests.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_git.py | Added tests for installing, uninstalling, and handling backups. |
| tests/test_cli_hooks.py | Added CLI tests for hooks install/uninstall commands. |
| src/pycomet/git.py | Introduced Git hook integration methods and backup handling. |
| src/pycomet/cli.py | Added new CLI commands to install and uninstall hooks. |
| docker-test.sh | Created a Docker test script for running hooks-related tests. |
| docker-compose.yml | Added services to run unit tests and hooks tests in Docker. |
| README.md | Updated documentation to include hooks installation instructions. |
| Dockerfile.test | Added test Dockerfile with necessary dependencies. |
| DEVELOPMENT.md | Extended the development guide with Docker testing and hooks integration instructions. |
| return True, "Prepare-commit-msg hook is already installed" | ||
| else: | ||
| # Backup existing hook | ||
| backup_path = Path(str(hook_path) + ".backup") |
Copilot
AI
May 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using an f-string for constructing backup_path for improved readability, e.g., Path(f"{hook_path}.backup").
| backup_path = Path(str(hook_path) + ".backup") | |
| backup_path = Path(f"{hook_path}.backup") |
| return False, "Not in a git repository" | ||
|
|
||
| hook_path = Path(git_root) / ".git" / "hooks" / "prepare-commit-msg" | ||
| backup_path = Path(str(hook_path) + ".backup") |
Copilot
AI
May 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using an f-string for constructing backup_path here as well, e.g., Path(f"{hook_path}.backup"), to maintain consistency and clarity.
| backup_path = Path(str(hook_path) + ".backup") | |
| backup_path = Path(f"{hook_path}.backup") |
This PR adds support for git hooks integration, specifically for the
prepare-commit-msghook. With this change, PyComet can automatically generate AI-powered commit messages when runninggit commit.Features
GitRepoclass to install/uninstall git hookshookswith:pycomet hooks install- Install the prepare-commit-msg hookpycomet hooks uninstall- Remove the hook and restore any backupgit commit(without-m)Usage
Install the git hook:
When installed, running
git commitwill automatically:To temporarily disable the hook for a specific commit:
To uninstall the hook:
Documentation was also updated in both README.md and DEVELOPMENT.md to explain this new feature.
Fixes #15.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.shcurl -LsSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.