git-commit-msg-ai 1.3.0__py3-none-any.whl → 1.4.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_commit_msg_ai/editor.py +10 -1
- git_commit_msg_ai/git_ops.py +10 -2
- {git_commit_msg_ai-1.3.0.dist-info → git_commit_msg_ai-1.4.1.dist-info}/METADATA +6 -6
- git_commit_msg_ai-1.4.1.dist-info/RECORD +11 -0
- git_commit_msg_ai-1.3.0.dist-info/RECORD +0 -11
- {git_commit_msg_ai-1.3.0.dist-info → git_commit_msg_ai-1.4.1.dist-info}/WHEEL +0 -0
- {git_commit_msg_ai-1.3.0.dist-info → git_commit_msg_ai-1.4.1.dist-info}/entry_points.txt +0 -0
- {git_commit_msg_ai-1.3.0.dist-info → git_commit_msg_ai-1.4.1.dist-info}/top_level.txt +0 -0
git_commit_msg_ai/editor.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import platform
|
|
2
3
|
import subprocess
|
|
3
4
|
import tempfile
|
|
4
5
|
|
|
5
6
|
from git_commit_msg_ai.exceptions import EditorError
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
def get_default_editor() -> str:
|
|
10
|
+
current_platform = platform.system()
|
|
11
|
+
is_windows = current_platform == 'Windows'
|
|
12
|
+
|
|
13
|
+
return 'notepad' if is_windows else 'vi'
|
|
14
|
+
|
|
15
|
+
|
|
8
16
|
def open_in_editor(initial_text: str) -> str:
|
|
9
17
|
try:
|
|
10
18
|
with tempfile.NamedTemporaryFile(suffix='.txt', mode='w', delete=False) as temp_file:
|
|
@@ -13,7 +21,8 @@ def open_in_editor(initial_text: str) -> str:
|
|
|
13
21
|
except OSError:
|
|
14
22
|
raise EditorError('Could not create a temporary file.')
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
platform_default_editor = get_default_editor()
|
|
25
|
+
editor_command = os.environ.get('EDITOR', platform_default_editor)
|
|
17
26
|
|
|
18
27
|
try:
|
|
19
28
|
try:
|
git_commit_msg_ai/git_ops.py
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import subprocess
|
|
2
|
+
from typing import Final
|
|
2
3
|
|
|
3
4
|
from git_commit_msg_ai.exceptions import GitError
|
|
4
5
|
|
|
6
|
+
GIT_COMMAND: Final[str] = 'git'
|
|
7
|
+
DIFF_SUBCOMMAND: Final[str] = 'diff'
|
|
8
|
+
CACHED_FLAG: Final[str] = '--cached'
|
|
9
|
+
COMMIT_SUBCOMMAND: Final[str] = 'commit'
|
|
10
|
+
MESSAGE_FLAG: Final[str] = '-m'
|
|
11
|
+
UTF8_ENCODING: Final[str] = 'utf-8'
|
|
12
|
+
|
|
5
13
|
|
|
6
14
|
def get_staged_diff() -> str:
|
|
7
15
|
try:
|
|
8
|
-
staged_diff = subprocess.check_output([
|
|
16
|
+
staged_diff = subprocess.check_output([GIT_COMMAND, DIFF_SUBCOMMAND, CACHED_FLAG]).decode(UTF8_ENCODING)
|
|
9
17
|
except FileNotFoundError:
|
|
10
18
|
raise GitError('git is not installed or not on PATH.')
|
|
11
19
|
except subprocess.CalledProcessError:
|
|
@@ -21,7 +29,7 @@ def get_staged_diff() -> str:
|
|
|
21
29
|
|
|
22
30
|
def commit(message: str) -> None:
|
|
23
31
|
try:
|
|
24
|
-
subprocess.run([
|
|
32
|
+
subprocess.run([GIT_COMMAND, COMMIT_SUBCOMMAND, MESSAGE_FLAG, message], check=True)
|
|
25
33
|
except FileNotFoundError:
|
|
26
34
|
raise GitError('git is not installed or not on PATH.')
|
|
27
35
|
except subprocess.CalledProcessError:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commit-msg-ai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: AI-powered git commit message generator following Conventional Commits
|
|
5
5
|
License-Expression: MIT
|
|
6
|
-
Requires-Python: >=3.
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: anthropic
|
|
9
9
|
Provides-Extra: dev
|
|
@@ -18,7 +18,7 @@ AI-powered git commit message generator that follows the [Conventional Commits](
|
|
|
18
18
|
|
|
19
19
|
## Prerequisites
|
|
20
20
|
|
|
21
|
-
- Python 3.
|
|
21
|
+
- Python 3.10+
|
|
22
22
|
- An Anthropic API key set as an environment variable:
|
|
23
23
|
|
|
24
24
|
```sh
|
|
@@ -53,9 +53,9 @@ The tool will:
|
|
|
53
53
|
[a]ccept / [e]dit / [r]eject:
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
- **a**
|
|
57
|
-
- **e**
|
|
58
|
-
- **r**
|
|
56
|
+
- **a** - commits immediately with the generated message
|
|
57
|
+
- **e** - opens the message in your `$EDITOR` (defaults to `notepad` on Windows, `vi` on Linux/macOS), lets you modify it, then commits
|
|
58
|
+
- **r** - exits without committing
|
|
59
59
|
|
|
60
60
|
## Commit message format
|
|
61
61
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
git_commit_msg_ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
git_commit_msg_ai/ai_client.py,sha256=RnzgIx1ieuiiH6w2VijA6_F-cs6tIQR57W1x3avg8lE,1887
|
|
3
|
+
git_commit_msg_ai/cli.py,sha256=s94orvxin-38vqUYWAO-j5_JZTzxBXbZSVOHYZ5KO_k,1059
|
|
4
|
+
git_commit_msg_ai/editor.py,sha256=JnVm5SZwkunyfOjisDKvTuPm3_NPbijVk_ho_yQy-3o,1430
|
|
5
|
+
git_commit_msg_ai/exceptions.py,sha256=7Hwluf3zHMjs4lpGktWS-Lwgo8y_4Xbb1WqzPQHkkUA,352
|
|
6
|
+
git_commit_msg_ai/git_ops.py,sha256=k2kjwcvj0Ac-WAttSsMP8pIl4-WXUKK47thgjaB62Og,1263
|
|
7
|
+
git_commit_msg_ai-1.4.1.dist-info/METADATA,sha256=9kdehx_hvkMAnv_TOUix-TxdPAU3Xd4ogCquDtJCWSg,2060
|
|
8
|
+
git_commit_msg_ai-1.4.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
9
|
+
git_commit_msg_ai-1.4.1.dist-info/entry_points.txt,sha256=KTu6wUhl0p3nf27k8L4vpSH_hpeRQpwzMPSmKv7K5Cs,65
|
|
10
|
+
git_commit_msg_ai-1.4.1.dist-info/top_level.txt,sha256=XYQC2BXvrcREGKEG7sm9nbwO7ifqcUSVgU7SW8BTURs,18
|
|
11
|
+
git_commit_msg_ai-1.4.1.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
git_commit_msg_ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
git_commit_msg_ai/ai_client.py,sha256=RnzgIx1ieuiiH6w2VijA6_F-cs6tIQR57W1x3avg8lE,1887
|
|
3
|
-
git_commit_msg_ai/cli.py,sha256=s94orvxin-38vqUYWAO-j5_JZTzxBXbZSVOHYZ5KO_k,1059
|
|
4
|
-
git_commit_msg_ai/editor.py,sha256=5X4cKFz2ry70BTtWQopSuDpGJGP3JwMcpa7vJpPbjyA,1180
|
|
5
|
-
git_commit_msg_ai/exceptions.py,sha256=7Hwluf3zHMjs4lpGktWS-Lwgo8y_4Xbb1WqzPQHkkUA,352
|
|
6
|
-
git_commit_msg_ai/git_ops.py,sha256=UJr3FUHPg8OTATy5Z5kbnXpy4Kh7fuORKR5HZV774NQ,970
|
|
7
|
-
git_commit_msg_ai-1.3.0.dist-info/METADATA,sha256=cIlbCpC92sAcvU1LLA4GsqgqbKLylX1l-2Pgl8BMBf8,2008
|
|
8
|
-
git_commit_msg_ai-1.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
9
|
-
git_commit_msg_ai-1.3.0.dist-info/entry_points.txt,sha256=KTu6wUhl0p3nf27k8L4vpSH_hpeRQpwzMPSmKv7K5Cs,65
|
|
10
|
-
git_commit_msg_ai-1.3.0.dist-info/top_level.txt,sha256=XYQC2BXvrcREGKEG7sm9nbwO7ifqcUSVgU7SW8BTURs,18
|
|
11
|
-
git_commit_msg_ai-1.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|