feat: add --message-file for commit-msg hook support - #12
Open
agherzan wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new --message-file mode to validate a single commit message directly from a file (e.g., .git/COMMIT_EDITMSG), enabling gitlance to run as a commit-msg hook before a commit object exists.
Changes:
- Add
--message-fileCLI option and code path to validate a message read from disk, mutually exclusive with ref/range validation options. - Add commit-msg git hook script and wire it into
task install-githooks. - Extend integration/unit tests to cover
--message-filebehavior and update CLI test harness.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/main.rs |
Adds --message-file mode and ref-based validation branching / updated exit behavior. |
src/git.rs |
Introduces Commit::from_message() and comment-stripping for message-file mode, plus unit tests. |
tests/integration_tests.rs |
Updates integration harness to support message-file mode and adds message-file integration tests. |
githooks/commit-msg |
New hook to run gitlance --message-file during git commit. |
Taskfile.yml |
Installs the new commit-msg hook alongside pre-push. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
tests/integration_tests.rs:379
file_path.to_str().unwrap()can panic without context if the path is not valid UTF-8. Preferexpect(...)(as used elsewhere in this file) to make failures actionable.
!run_check(
Some("wip-fixup"),
None,
None,
None,
Some(file_path.to_str().unwrap())
),
tests/integration_tests.rs:412
file_path.to_str().unwrap()can panic without context if the path is not valid UTF-8. Preferexpect(...)for a clearer panic message if conversion fails.
!run_check(
Some("all"),
None,
None,
None,
Some(file_path.to_str().unwrap())
),
Enables validation of commit messages before the git object exists, allowing gitlance to work as a commit-msg hook. Comment lines are ignored, matching how a commit message is interpreted. The new mode/argument is mutually exclusive with the ref-based options (--base, --head, --repo, --skip-merge-commits), which are only meaningful when validating existing commits. Signed-off-by: Andrei Gherzan <andrei.gherzan@canonical.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enables validation of commit messages before the git object exists, allowing gitlance to work as a commit-msg hook. Comment lines are ignored, matching how a commit message is interpreted.
The new mode/argument is mutually exclusive with the ref-based options (--base, --head, --repo, --skip-merge-commits), which are only meaningful when validating existing commits.