git-copilot-commit 0.3.6__tar.gz → 0.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-copilot-commit
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: Automatically generate and commit changes using copilot
5
5
  Author-email: Dheepak Krishnamurthy <1813121+kdheepak@users.noreply.github.com>
6
6
  License-File: LICENSE
@@ -165,6 +165,27 @@ def generate_commit_message(
165
165
  return ask(fallback_prompt, model=model)
166
166
 
167
167
 
168
+ def commit_with_retry_no_verify(
169
+ repo: GitRepository, message: str, use_editor: bool = False
170
+ ) -> str:
171
+ """Run commit and offer one retry with -n on failure."""
172
+ try:
173
+ return repo.commit(message, use_editor=use_editor)
174
+ except GitError as e:
175
+ console.print(f"[red]Commit failed: {e}[/red]")
176
+ if not Confirm.ask(
177
+ "Retry commit with [bold]`-n`[/] (skip hooks) using the same commit message?",
178
+ default=True,
179
+ ):
180
+ raise typer.Exit(1)
181
+
182
+ try:
183
+ return repo.commit(message, use_editor=use_editor, no_verify=True)
184
+ except GitError as retry_error:
185
+ console.print(f"[red]Commit with -n failed: {retry_error}[/red]")
186
+ raise typer.Exit(1)
187
+
188
+
168
189
  @app.command()
169
190
  def commit(
170
191
  all_files: bool = typer.Option(
@@ -255,11 +276,7 @@ def commit(
255
276
  # Confirm commit or edit message (skip if --yes flag is used)
256
277
  if yes:
257
278
  # Automatically commit with generated message
258
- try:
259
- commit_sha = repo.commit(commit_message)
260
- except GitError as e:
261
- console.print(f"[red]Commit failed: {e}[/red]")
262
- raise typer.Exit(1)
279
+ commit_sha = commit_with_retry_no_verify(repo, commit_message)
263
280
  else:
264
281
  choice = typer.prompt(
265
282
  "Choose action: (c)ommit, (e)dit message, (q)uit",
@@ -273,18 +290,12 @@ def commit(
273
290
  elif choice == "e":
274
291
  # Use git's built-in editor with generated message as template
275
292
  console.print("[cyan]Opening git editor...[/cyan]")
276
- try:
277
- commit_sha = repo.commit(commit_message, use_editor=True)
278
- except GitError as e:
279
- console.print(f"[red]Commit failed: {e}[/red]")
280
- raise typer.Exit(1)
293
+ commit_sha = commit_with_retry_no_verify(
294
+ repo, commit_message, use_editor=True
295
+ )
281
296
  elif choice == "c":
282
297
  # Commit with generated message
283
- try:
284
- commit_sha = repo.commit(commit_message)
285
- except GitError as e:
286
- console.print(f"[red]Commit failed: {e}[/red]")
287
- raise typer.Exit(1)
298
+ commit_sha = commit_with_retry_no_verify(repo, commit_message)
288
299
  else:
289
300
  console.print("Invalid choice. Commit cancelled.")
290
301
  raise typer.Exit()
@@ -226,13 +226,19 @@ class GitRepository:
226
226
  else:
227
227
  self._run_git_command(["reset", "HEAD"] + paths)
228
228
 
229
- def commit(self, message: str | None = None, use_editor: bool = False) -> str:
229
+ def commit(
230
+ self,
231
+ message: str | None = None,
232
+ use_editor: bool = False,
233
+ no_verify: bool = False,
234
+ ) -> str:
230
235
  """
231
236
  Create a commit with the given message or using git's editor.
232
237
 
233
238
  Args:
234
239
  message: Commit message. Used as template if use_editor is True.
235
240
  use_editor: Whether to use git's configured editor.
241
+ no_verify: Skip pre-commit and commit-msg hooks (git commit -n).
236
242
 
237
243
  Returns:
238
244
  Commit SHA.
@@ -253,7 +259,10 @@ class GitRepository:
253
259
  temp_file = f.name
254
260
 
255
261
  try:
256
- args = ["commit", "-e", "-F", temp_file]
262
+ args = ["commit"]
263
+ if no_verify:
264
+ args.append("-n")
265
+ args.extend(["-e", "-F", temp_file])
257
266
 
258
267
  # Run interactively without capturing output
259
268
  cmd = ["git"] + args
@@ -273,7 +282,10 @@ class GitRepository:
273
282
  else:
274
283
  if message is None:
275
284
  raise ValueError("message is required when use_editor is False")
276
- args = ["commit", "-m", message]
285
+ args = ["commit"]
286
+ if no_verify:
287
+ args.append("-n")
288
+ args.extend(["-m", message])
277
289
 
278
290
  self._run_git_command(args)
279
291