-
Notifications
You must be signed in to change notification settings - Fork 122
feat: add pre-commit hook support #1250 #1264
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
Changes from all commits
c85d313
eb7b4c4
e776a3f
a152823
adb14cc
31b90b4
0789790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ Cargo.lock | |
| .vscode | ||
| .zed | ||
| .trae | ||
| *.code-workspace | ||
|
|
||
| # Mac | ||
| .DS_Store | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||
| use std::process::Stdio; | ||||||
| use std::str::FromStr; | ||||||
| use std::{collections::HashSet, path::PathBuf}; | ||||||
|
|
||||||
|
|
@@ -15,6 +16,7 @@ use mercury::internal::index::Index; | |||||
| use mercury::internal::object::commit::Commit; | ||||||
| use mercury::internal::object::tree::{Tree, TreeItem, TreeItemMode}; | ||||||
| use mercury::internal::object::ObjectTrait; | ||||||
| use std::process::Command; | ||||||
|
|
||||||
| use super::save_object; | ||||||
|
|
||||||
|
|
@@ -38,6 +40,9 @@ pub struct CommitArgs { | |||||
| /// add signed-off-by line at the end of the commit message | ||||||
| #[arg(short = 's', long)] | ||||||
| pub signoff: bool, | ||||||
|
|
||||||
| #[arg(long)] | ||||||
| pub disable_pre: bool, | ||||||
| } | ||||||
|
|
||||||
| pub async fn execute(args: CommitArgs) { | ||||||
|
|
@@ -49,6 +54,46 @@ pub async fn execute(args: CommitArgs) { | |||||
| panic!("fatal: no changes added to commit, use --allow-empty to override"); | ||||||
| } | ||||||
|
|
||||||
| // run pre commit hook | ||||||
|
||||||
| // run pre commit hook | |
| // run pre-commit hook |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||
|
|
||||||
| #!/bin/sh | ||||||
|
||||||
| #!/bin/sh | |
| #!/usr/bin/env pwsh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/sh | ||
|
|
||
|
|
||
| # Pre-commit hook example | ||
| # Exit with 0 to allow commit, non-zero to reject | ||
|
|
||
| # Example | ||
| # echo "Running pre-commit hook" | ||
|
|
||
|
|
||
| exit 0 |
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.
The
disable_preargument is missing documentation. Add a doc comment to explain its purpose, similar to other arguments in the struct.