git-copilot-commit 0.7.0__py3-none-any.whl → 0.7.1__py3-none-any.whl

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.
git_copilot_commit/git.py CHANGED
@@ -267,6 +267,20 @@ class GitRepository:
267
267
  result = self._run_git_command(["rev-parse", ref])
268
268
  return result.stdout.strip()
269
269
 
270
+ def get_tree_sha(self, ref: str = "HEAD") -> str:
271
+ """Resolve a git ref to its tree SHA."""
272
+ result = self._run_git_command(["rev-parse", f"{ref}^{{tree}}"])
273
+ return result.stdout.strip()
274
+
275
+ def get_empty_tree_sha(self) -> str:
276
+ """Create and return the repository's empty tree SHA."""
277
+ result = self._run_git_command(["mktree"], input_text="")
278
+ tree_sha = result.stdout.strip()
279
+ if tree_sha:
280
+ return tree_sha
281
+
282
+ raise GitCommandError("Git command failed: git mktree")
283
+
270
284
  def has_commit(self, ref: str = "HEAD") -> bool:
271
285
  """Return whether the provided ref resolves to a commit."""
272
286
  result = self._run_git_command(
@@ -530,12 +544,19 @@ class GitRepository:
530
544
  use_editor: bool = False,
531
545
  ) -> str:
532
546
  """Create a commit from an alternate index using plumbing commands only."""
547
+ has_parent = self.has_commit("HEAD")
548
+ parent_refs = ("HEAD",) if has_parent else ()
549
+ base_tree_sha = (
550
+ self.get_tree_sha("HEAD") if has_parent else self.get_empty_tree_sha()
551
+ )
552
+ tree_sha = self.write_tree(env=index.env)
553
+ if tree_sha == base_tree_sha:
554
+ raise GitCommandError("No changes to commit")
555
+
533
556
  commit_message = message
534
557
  if use_editor:
535
558
  commit_message = self.edit_commit_message(message, env=index.env)
536
559
 
537
- parent_refs = ("HEAD",) if self.has_commit("HEAD") else ()
538
- tree_sha = self.write_tree(env=index.env)
539
560
  commit_sha = self.create_commit_object(
540
561
  tree_sha,
541
562
  message=commit_message,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-copilot-commit
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Automatically generate and commit changes using GitHub Copilot or OpenAI-compatible LLMs
5
5
  Author-email: Dheepak Krishnamurthy <1813121+kdheepak@users.noreply.github.com>
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  git_copilot_commit/__init__.py,sha256=v3x5oBkxwKJEZLv62QqSmP3iqNKLtZgrWZfH8eFzlQg,60
2
2
  git_copilot_commit/cli.py,sha256=ZlrXY6c4JUxMqLEkykhnNTgoegOfxLq9Pp7Yqy1PuOk,40391
3
- git_copilot_commit/git.py,sha256=EbXiicWygSlMM-F6rY4LCkchwCvsFTziJcdUZM-1vnw,21059
3
+ git_copilot_commit/git.py,sha256=o1kJXhqV9WRRUkfla5oMRG0qskdd5s1wYEUpLKhhVKw,21849
4
4
  git_copilot_commit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  git_copilot_commit/settings.py,sha256=WrM10_J3F7QBfOVmPDWpNZrNHhmZSeN-9FqQZxgdWvQ,3730
6
6
  git_copilot_commit/split_commits.py,sha256=rHyuVJggjmYjbva7BVqsM3aZRxUgOKkuZtxxvFRcu6Q,15060
@@ -12,8 +12,8 @@ git_copilot_commit/llms/openai_api.py,sha256=--6RVwxV2aGsJT2paJzv86CihoPczpfEVFA
12
12
  git_copilot_commit/llms/providers.py,sha256=N0DLkfRP-Z85kcYYoXWWHXr5nIwXUXDV88skS-NXLpU,11649
13
13
  git_copilot_commit/prompts/commit-message-generator-prompt.md,sha256=3Dz8GCdumFNAtXOdTlpRtgBnmX0WyrPL6tdfMgNyYiE,2411
14
14
  git_copilot_commit/prompts/split-commit-planner-prompt.md,sha256=tDI0v1udOhkRQM31M892FMzcPMYHExnU0fjTGia1V2k,1510
15
- git_copilot_commit-0.7.0.dist-info/METADATA,sha256=lI1E3-S5S1HEsTFOaqPuXwPE0WCF2kNx_mrWZFNReyg,10006
16
- git_copilot_commit-0.7.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
17
- git_copilot_commit-0.7.0.dist-info/entry_points.txt,sha256=-D4bQqiuSPwQJG2zx--vJbZD1iqB5coUfoJ_gmC3rSg,66
18
- git_copilot_commit-0.7.0.dist-info/licenses/LICENSE,sha256=14lNZAoKJPI1U7eGpletjN_PFm1JwP1vT_0jFKY6eWg,1065
19
- git_copilot_commit-0.7.0.dist-info/RECORD,,
15
+ git_copilot_commit-0.7.1.dist-info/METADATA,sha256=eEeMahFNChxTW828tsN_ckjAS8m176msK1GzynTw7dc,10006
16
+ git_copilot_commit-0.7.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
17
+ git_copilot_commit-0.7.1.dist-info/entry_points.txt,sha256=-D4bQqiuSPwQJG2zx--vJbZD1iqB5coUfoJ_gmC3rSg,66
18
+ git_copilot_commit-0.7.1.dist-info/licenses/LICENSE,sha256=14lNZAoKJPI1U7eGpletjN_PFm1JwP1vT_0jFKY6eWg,1065
19
+ git_copilot_commit-0.7.1.dist-info/RECORD,,