feat(cli): add --no-verify option to bypass git hooks during commit

This commit is contained in:
sankalp committed 2025-08-25 14:50:01 +05:45
1 parent 3df312a7fb
commit 95bb2bc73b
2 files changed
+40 -4

No files matched your search

+29 -2
View File
@@ -70,17 +70,19 @@ class GitService:
files = self.get_staged_files() if staged else self.get_unstaged_files()
return {file: self.get_diff(file, staged) for file in files}
def commit(self, message: str, sign: bool = False) -> bool:
def commit(self, message: str, sign: bool = False, no_verify: bool = False) -> bool:
"""Create a commit with the given message."""
args = ["commit"]
if sign:
args.append("-S")
if no_verify:
args.append("--no-verify")
args.extend(["-m", message])
stdout, stderr, returncode = self._run_git_command(args)
return returncode == 0
def commit_verbose(
self, message: str, sign: bool = False
self, message: str, sign: bool = False, no_verify: bool = False
) -> Tuple[bool, str, str, int]:
"""Create a commit and return success and raw outputs.
@@ -90,10 +92,35 @@ class GitService:
args = ["commit"]
if sign:
args.append("-S")
if no_verify:
args.append("--no-verify")
args.extend(["-m", message])
stdout, stderr, returncode = self._run_git_command(args)
return returncode == 0, stdout, stderr, returncode
def commit_paths_verbose(
self,
message: str,
files: List[str],
sign: bool = False,
no_verify: bool = False,
) -> Tuple[bool, str, str, int]:
"""Create a commit including only the specified files.
Returns:
(ok, stdout, stderr, returncode)
"""
if not files:
return False, "", "no files specified", 1
args = ["commit"]
if sign:
args.append("-S")
if no_verify:
args.append("--no-verify")
args.extend(["-m", message, "--"] + list(files))
stdout, stderr, returncode = self._run_git_command(args)
return returncode == 0, stdout, stderr, returncode
def commit_paths_verbose(
self, message: str, files: List[str], sign: bool = False
) -> Tuple[bool, str, str, int]: