git-copilot-commit 0.5.5__py3-none-any.whl → 0.5.6__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 +21 -6
- {git_copilot_commit-0.5.5.dist-info → git_copilot_commit-0.5.6.dist-info}/METADATA +1 -1
- {git_copilot_commit-0.5.5.dist-info → git_copilot_commit-0.5.6.dist-info}/RECORD +6 -6
- {git_copilot_commit-0.5.5.dist-info → git_copilot_commit-0.5.6.dist-info}/WHEEL +0 -0
- {git_copilot_commit-0.5.5.dist-info → git_copilot_commit-0.5.6.dist-info}/entry_points.txt +0 -0
- {git_copilot_commit-0.5.5.dist-info → git_copilot_commit-0.5.6.dist-info}/licenses/LICENSE +0 -0
git_copilot_commit/git.py
CHANGED
|
@@ -139,7 +139,9 @@ class GitRepository:
|
|
|
139
139
|
except subprocess.CalledProcessError:
|
|
140
140
|
raise NotAGitRepositoryError(f"{self.cwd} is not a git repository")
|
|
141
141
|
except subprocess.TimeoutExpired:
|
|
142
|
-
raise GitCommandError(
|
|
142
|
+
raise GitCommandError(
|
|
143
|
+
"Git command timed out: git rev-parse --show-toplevel"
|
|
144
|
+
)
|
|
143
145
|
|
|
144
146
|
repo_root = result.stdout.strip()
|
|
145
147
|
if not repo_root:
|
|
@@ -264,10 +266,18 @@ class GitRepository:
|
|
|
264
266
|
result = self._run_git_command(["rev-parse", ref])
|
|
265
267
|
return result.stdout.strip()
|
|
266
268
|
|
|
269
|
+
def has_commit(self, ref: str = "HEAD") -> bool:
|
|
270
|
+
"""Return whether the provided ref resolves to a commit."""
|
|
271
|
+
result = self._run_git_command(
|
|
272
|
+
["rev-parse", "--verify", "--quiet", f"{ref}^{{commit}}"],
|
|
273
|
+
check=False,
|
|
274
|
+
)
|
|
275
|
+
return result.returncode == 0
|
|
276
|
+
|
|
267
277
|
def _parse_status_output(self, status_output: str) -> list[GitFile]:
|
|
268
278
|
"""Parse git status --porcelain output into GitFile objects."""
|
|
269
279
|
files = []
|
|
270
|
-
for line in status_output.
|
|
280
|
+
for line in status_output.splitlines():
|
|
271
281
|
if not line:
|
|
272
282
|
continue
|
|
273
283
|
|
|
@@ -318,12 +328,13 @@ class GitRepository:
|
|
|
318
328
|
|
|
319
329
|
def create_alternate_index(self, from_ref: str = "HEAD") -> AlternateGitIndex:
|
|
320
330
|
"""Create a temporary git index initialized from the provided ref."""
|
|
321
|
-
fd, index_path = tempfile.mkstemp(
|
|
322
|
-
prefix="git-copilot-commit-", suffix=".index"
|
|
323
|
-
)
|
|
331
|
+
fd, index_path = tempfile.mkstemp(prefix="git-copilot-commit-", suffix=".index")
|
|
324
332
|
os.close(fd)
|
|
325
333
|
alternate_index = AlternateGitIndex(Path(index_path))
|
|
326
|
-
self.
|
|
334
|
+
if from_ref == "HEAD" and not self.has_commit(from_ref):
|
|
335
|
+
self.read_empty_tree(index=alternate_index)
|
|
336
|
+
else:
|
|
337
|
+
self.read_tree(from_ref, index=alternate_index)
|
|
327
338
|
return alternate_index
|
|
328
339
|
|
|
329
340
|
@contextmanager
|
|
@@ -341,6 +352,10 @@ class GitRepository:
|
|
|
341
352
|
"""Populate an alternate index from the provided ref."""
|
|
342
353
|
self._run_git_command(["read-tree", ref], env=index.env)
|
|
343
354
|
|
|
355
|
+
def read_empty_tree(self, *, index: AlternateGitIndex) -> None:
|
|
356
|
+
"""Initialize an alternate index with an empty tree."""
|
|
357
|
+
self._run_git_command(["read-tree", "--empty"], env=index.env)
|
|
358
|
+
|
|
344
359
|
def apply_patch(
|
|
345
360
|
self,
|
|
346
361
|
patch: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
git_copilot_commit/__init__.py,sha256=v3x5oBkxwKJEZLv62QqSmP3iqNKLtZgrWZfH8eFzlQg,60
|
|
2
2
|
git_copilot_commit/cli.py,sha256=yN7fq43i3TFerhEOMm4ZHUy2rbiH0n70tIcwrxdWCdc,33929
|
|
3
|
-
git_copilot_commit/git.py,sha256=
|
|
3
|
+
git_copilot_commit/git.py,sha256=hCTcnZC3S8B-b5NY8KbGvlXmHZ_XGwezVW9W9UdrHZE,15612
|
|
4
4
|
git_copilot_commit/github_copilot.py,sha256=2SKVVFmQ2yETAySjSRYKQTujW-1vZEW4rFKSr--dtLs,50427
|
|
5
5
|
git_copilot_commit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
git_copilot_commit/settings.py,sha256=WrM10_J3F7QBfOVmPDWpNZrNHhmZSeN-9FqQZxgdWvQ,3730
|
|
@@ -8,8 +8,8 @@ git_copilot_commit/split_commits.py,sha256=rHyuVJggjmYjbva7BVqsM3aZRxUgOKkuZtxxv
|
|
|
8
8
|
git_copilot_commit/version.py,sha256=AieHOUX52g6N67HL0iLWtDKrgOYyulxwHWViu26Jrd4,105
|
|
9
9
|
git_copilot_commit/prompts/commit-message-generator-prompt.md,sha256=EHAS6w15vLQ-kgT1N7nPG2nWqdeTmlHje_kN9yZIoZQ,2378
|
|
10
10
|
git_copilot_commit/prompts/split-commit-planner-prompt.md,sha256=JActWTKMbdR9eaJyCbQ6UwzyRu5jJi8Iec7H7qWAmAA,1418
|
|
11
|
-
git_copilot_commit-0.5.
|
|
12
|
-
git_copilot_commit-0.5.
|
|
13
|
-
git_copilot_commit-0.5.
|
|
14
|
-
git_copilot_commit-0.5.
|
|
15
|
-
git_copilot_commit-0.5.
|
|
11
|
+
git_copilot_commit-0.5.6.dist-info/METADATA,sha256=HGW7Q_WqyozLqPsmU1mefJwdTcpGD4ieQF8c9TEIIDE,6649
|
|
12
|
+
git_copilot_commit-0.5.6.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
13
|
+
git_copilot_commit-0.5.6.dist-info/entry_points.txt,sha256=-D4bQqiuSPwQJG2zx--vJbZD1iqB5coUfoJ_gmC3rSg,66
|
|
14
|
+
git_copilot_commit-0.5.6.dist-info/licenses/LICENSE,sha256=14lNZAoKJPI1U7eGpletjN_PFm1JwP1vT_0jFKY6eWg,1065
|
|
15
|
+
git_copilot_commit-0.5.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|