gmsg 0.1.4__tar.gz → 0.1.6__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.
- gmsg-0.1.6/PKG-INFO +142 -0
- gmsg-0.1.6/README.md +122 -0
- {gmsg-0.1.4 → gmsg-0.1.6}/gmsg/api_key.py +5 -4
- {gmsg-0.1.4 → gmsg-0.1.6}/gmsg/gmsg.py +17 -14
- gmsg-0.1.6/pyproject.toml +25 -0
- gmsg-0.1.4/PKG-INFO +0 -18
- gmsg-0.1.4/README.md +0 -0
- gmsg-0.1.4/pyproject.toml +0 -21
- {gmsg-0.1.4 → gmsg-0.1.6}/LICENSE +0 -0
- {gmsg-0.1.4 → gmsg-0.1.6}/gmsg/__init__.py +0 -0
gmsg-0.1.6/PKG-INFO
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: gmsg
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: Generates git commit messages for you using AI.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: git,commit,ai
|
|
7
|
+
Author: Shiyan Shirani
|
|
8
|
+
Author-email: shiyan99s@gmail.com
|
|
9
|
+
Requires-Python: >=3.9.5
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: cryptography (>=45.0.2,<46.0.0)
|
|
17
|
+
Requires-Dist: google-genai (>=1.9.0,<2.0.0)
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# gmsg
|
|
21
|
+
|
|
22
|
+
A command-line tool that automatically generates concise and meaningful Git commit messages using Google's Gemini model based on your staged changes.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🚀 Features
|
|
27
|
+
|
|
28
|
+
* ✅ Detects if the current directory is a Git repository
|
|
29
|
+
* ✅ Retrieves your staged changes via `git diff --cached`
|
|
30
|
+
* ✅ Uses Gemini (for now) to generate a one-liner commit message
|
|
31
|
+
* ✅ Allows you to:
|
|
32
|
+
|
|
33
|
+
* Accept the suggestion
|
|
34
|
+
* Edit the message in your preferred text editor
|
|
35
|
+
* Regenerate a new suggestion
|
|
36
|
+
* ✅ Automatically commits the changes with your selected message
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📦 Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install gmsg
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🛠️ Configuration
|
|
49
|
+
|
|
50
|
+
Get your [Google Gemini API key](https://aistudio.google.com/app/apikey) if you don't have already.
|
|
51
|
+
|
|
52
|
+
### 1. Set API key
|
|
53
|
+
|
|
54
|
+
Enter your api key when package is used for the first time.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
$ Enter your Gemini API KEY:
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ⚙️ Usage
|
|
63
|
+
|
|
64
|
+
1. Stage your changes:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git add .
|
|
68
|
+
or
|
|
69
|
+
git add <file>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. Run the package:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
gmsg
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
3. Follow the prompts:
|
|
79
|
+
|
|
80
|
+
* Press `y/Y/enter` to commit with the suggested message
|
|
81
|
+
* Press `e` to edit the message in your default `$EDITOR` (e.g., `vim`)
|
|
82
|
+
* Press `n` to regenerate the commit message
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ✨ Example
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
$ git add some_file.py
|
|
90
|
+
$ gmsg
|
|
91
|
+
|
|
92
|
+
> Generate a one liner git commit message for these changes...
|
|
93
|
+
> Added error handling in API response parser
|
|
94
|
+
|
|
95
|
+
Do you want to continue with this message? [Y = yes / e = edit / n = no]: y
|
|
96
|
+
Running: `git commit -m Added error handling in API response parser`
|
|
97
|
+
Message committed to git. You can run `git commit --amend` to modify it.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 🧩 Requirements
|
|
103
|
+
|
|
104
|
+
* Python 3.10+
|
|
105
|
+
* Git installed and available in your system path
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 📍 Roadmap
|
|
109
|
+
|
|
110
|
+
Here are some upcoming features and improvements planned for this project:
|
|
111
|
+
* [ ] **CLI Arguments Support**
|
|
112
|
+
Add flags like `--gin` to mention 'git issue number' in the commit.
|
|
113
|
+
|
|
114
|
+
* [ ] **CLI Arguments Support**
|
|
115
|
+
Add flags like `--dry-run` for non-interactive use.
|
|
116
|
+
|
|
117
|
+
* [ ] **Multi-line Commit Messages**
|
|
118
|
+
Option to generate more descriptive, multi-line messages with summaries and bullet points.
|
|
119
|
+
|
|
120
|
+
* [ ] **Better Diff Parsing**
|
|
121
|
+
Use syntax-aware parsing to improve prompt context and generate more accurate commit messages.
|
|
122
|
+
|
|
123
|
+
* [ ] **Git Hook Integration**
|
|
124
|
+
Provide an installable Git commit hook that auto-runs this tool on `git commit`.
|
|
125
|
+
|
|
126
|
+
* [ ] **Support for Other LLMs**
|
|
127
|
+
Add support for OpenAI's GPT, Claude, or local models using plugins/adapters.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## 📝 License
|
|
133
|
+
|
|
134
|
+
MIT License. Feel free to use, modify, and contribute!
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🤝 Contributing
|
|
139
|
+
|
|
140
|
+
Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
|
|
141
|
+
|
|
142
|
+
|
gmsg-0.1.6/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# gmsg
|
|
2
|
+
|
|
3
|
+
A command-line tool that automatically generates concise and meaningful Git commit messages using Google's Gemini model based on your staged changes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
* ✅ Detects if the current directory is a Git repository
|
|
10
|
+
* ✅ Retrieves your staged changes via `git diff --cached`
|
|
11
|
+
* ✅ Uses Gemini (for now) to generate a one-liner commit message
|
|
12
|
+
* ✅ Allows you to:
|
|
13
|
+
|
|
14
|
+
* Accept the suggestion
|
|
15
|
+
* Edit the message in your preferred text editor
|
|
16
|
+
* Regenerate a new suggestion
|
|
17
|
+
* ✅ Automatically commits the changes with your selected message
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 📦 Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install gmsg
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🛠️ Configuration
|
|
30
|
+
|
|
31
|
+
Get your [Google Gemini API key](https://aistudio.google.com/app/apikey) if you don't have already.
|
|
32
|
+
|
|
33
|
+
### 1. Set API key
|
|
34
|
+
|
|
35
|
+
Enter your api key when package is used for the first time.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
$ Enter your Gemini API KEY:
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ⚙️ Usage
|
|
44
|
+
|
|
45
|
+
1. Stage your changes:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git add .
|
|
49
|
+
or
|
|
50
|
+
git add <file>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. Run the package:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
gmsg
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
3. Follow the prompts:
|
|
60
|
+
|
|
61
|
+
* Press `y/Y/enter` to commit with the suggested message
|
|
62
|
+
* Press `e` to edit the message in your default `$EDITOR` (e.g., `vim`)
|
|
63
|
+
* Press `n` to regenerate the commit message
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## ✨ Example
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ git add some_file.py
|
|
71
|
+
$ gmsg
|
|
72
|
+
|
|
73
|
+
> Generate a one liner git commit message for these changes...
|
|
74
|
+
> Added error handling in API response parser
|
|
75
|
+
|
|
76
|
+
Do you want to continue with this message? [Y = yes / e = edit / n = no]: y
|
|
77
|
+
Running: `git commit -m Added error handling in API response parser`
|
|
78
|
+
Message committed to git. You can run `git commit --amend` to modify it.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 🧩 Requirements
|
|
84
|
+
|
|
85
|
+
* Python 3.10+
|
|
86
|
+
* Git installed and available in your system path
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📍 Roadmap
|
|
90
|
+
|
|
91
|
+
Here are some upcoming features and improvements planned for this project:
|
|
92
|
+
* [ ] **CLI Arguments Support**
|
|
93
|
+
Add flags like `--gin` to mention 'git issue number' in the commit.
|
|
94
|
+
|
|
95
|
+
* [ ] **CLI Arguments Support**
|
|
96
|
+
Add flags like `--dry-run` for non-interactive use.
|
|
97
|
+
|
|
98
|
+
* [ ] **Multi-line Commit Messages**
|
|
99
|
+
Option to generate more descriptive, multi-line messages with summaries and bullet points.
|
|
100
|
+
|
|
101
|
+
* [ ] **Better Diff Parsing**
|
|
102
|
+
Use syntax-aware parsing to improve prompt context and generate more accurate commit messages.
|
|
103
|
+
|
|
104
|
+
* [ ] **Git Hook Integration**
|
|
105
|
+
Provide an installable Git commit hook that auto-runs this tool on `git commit`.
|
|
106
|
+
|
|
107
|
+
* [ ] **Support for Other LLMs**
|
|
108
|
+
Add support for OpenAI's GPT, Claude, or local models using plugins/adapters.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## 📝 License
|
|
114
|
+
|
|
115
|
+
MIT License. Feel free to use, modify, and contribute!
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🤝 Contributing
|
|
120
|
+
|
|
121
|
+
Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
|
|
122
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import os
|
|
3
|
+
import getpass
|
|
3
4
|
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
|
|
@@ -11,13 +12,13 @@ def get_or_set_api_key():
|
|
|
11
12
|
print(
|
|
12
13
|
"Get your key from https://ai.google.dev/gemini-api/docs/api-key"
|
|
13
14
|
)
|
|
14
|
-
key_inp =
|
|
15
|
-
with open(rc,
|
|
16
|
-
|
|
15
|
+
key_inp = getpass.getpass("Enter your Gemini API KEY: ").strip()
|
|
16
|
+
with open(rc, "w") as file:
|
|
17
|
+
file.write(key_inp)
|
|
17
18
|
|
|
18
19
|
return key_inp
|
|
19
20
|
|
|
20
|
-
with open(rc,
|
|
21
|
+
with open(rc, "r") as f:
|
|
21
22
|
return f.read().strip()
|
|
22
23
|
except KeyboardInterrupt:
|
|
23
24
|
sys.exit(0)
|
|
@@ -4,7 +4,8 @@ import tempfile
|
|
|
4
4
|
import subprocess
|
|
5
5
|
from google import genai
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from .api_key import get_or_set_api_key
|
|
7
|
+
# from .api_key import get_or_set_api_key
|
|
8
|
+
from api_key import get_or_set_api_key
|
|
8
9
|
|
|
9
10
|
GREEN = "\033[92m"
|
|
10
11
|
RED = "\033[91m"
|
|
@@ -44,13 +45,14 @@ def trigger_query(query: str, api_key: str) -> str:
|
|
|
44
45
|
client = genai.Client(api_key=api_key)
|
|
45
46
|
msg = client.models.generate_content(model="gemini-2.0-flash",
|
|
46
47
|
contents=query)
|
|
47
|
-
return msg.text
|
|
48
|
+
return msg.text.strip()
|
|
48
49
|
except genai.errors.ClientError as error:
|
|
49
50
|
if error.code == 400:
|
|
50
|
-
printt(
|
|
51
|
+
printt("Gemini API key is invalid, check ~/.gmsg",
|
|
51
52
|
is_success=False)
|
|
53
|
+
sys.exit(1)
|
|
52
54
|
else:
|
|
53
|
-
|
|
55
|
+
print(error, is_success=False)
|
|
54
56
|
sys.exit(1)
|
|
55
57
|
|
|
56
58
|
|
|
@@ -59,24 +61,25 @@ def cycle_through_messages(diff: str, api_key: str) -> bool:
|
|
|
59
61
|
msg = trigger_query(query, api_key)
|
|
60
62
|
|
|
61
63
|
while True:
|
|
62
|
-
printt(msg)
|
|
64
|
+
printt(msg + '\n')
|
|
63
65
|
action = input(
|
|
64
|
-
"Do you want to continue with this message?
|
|
66
|
+
"Do you want to continue with this message? c(continue) / e(edit) / r(regenerate) / a(abort): "
|
|
65
67
|
).strip().lower()
|
|
66
|
-
if action
|
|
68
|
+
if action == "c":
|
|
67
69
|
print(
|
|
68
70
|
f"Running: `git commit -m {msg}`\nMessage committed to git. You can run `git commit --amend` to modify it."
|
|
69
71
|
)
|
|
70
72
|
|
|
71
73
|
commit_message_to_git(msg)
|
|
72
74
|
break
|
|
73
|
-
elif action
|
|
75
|
+
elif action == "r":
|
|
74
76
|
msg = trigger_query(query, api_key)
|
|
75
|
-
elif action
|
|
77
|
+
elif action == "e":
|
|
76
78
|
msg = edit_message_in_editor(msg)
|
|
77
|
-
|
|
79
|
+
elif action == "a":
|
|
80
|
+
sys.exit(1)
|
|
78
81
|
else:
|
|
79
|
-
print("
|
|
82
|
+
print("warning: invalid input")
|
|
80
83
|
|
|
81
84
|
|
|
82
85
|
def commit_message_to_git(generated_msg: str) -> str | None:
|
|
@@ -118,16 +121,16 @@ def printt(text: str, is_success: bool = True):
|
|
|
118
121
|
|
|
119
122
|
def main():
|
|
120
123
|
try:
|
|
124
|
+
user_api_key = get_or_set_api_key()
|
|
121
125
|
if not is_git_repo():
|
|
122
|
-
printt("
|
|
126
|
+
printt("warning: not a git repository.", is_success=False)
|
|
123
127
|
sys.exit(1)
|
|
124
128
|
|
|
125
129
|
diff = git_diff()
|
|
126
130
|
if not diff:
|
|
127
|
-
printt("
|
|
131
|
+
printt("warning: no staged changes found", is_success=False)
|
|
128
132
|
sys.exit(1)
|
|
129
133
|
|
|
130
|
-
user_api_key = get_or_set_api_key()
|
|
131
134
|
cycle_through_messages(diff, user_api_key)
|
|
132
135
|
|
|
133
136
|
except KeyboardInterrupt:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "gmsg"
|
|
3
|
+
version = "0.1.6"
|
|
4
|
+
description = "Generates git commit messages for you using AI."
|
|
5
|
+
authors = ["Shiyan Shirani <shiyan99s@gmail.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
packages = [{ include = "gmsg" }]
|
|
9
|
+
keywords = ["git", "commit", "ai"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License"
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[tool.poetry.dependencies]
|
|
16
|
+
python = ">=3.9.5"
|
|
17
|
+
google-genai = ">=1.9.0,<2.0.0"
|
|
18
|
+
cryptography = "^45.0.2"
|
|
19
|
+
|
|
20
|
+
[tool.poetry.scripts]
|
|
21
|
+
gmsg = "gmsg.gmsg:main"
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["poetry-core>=1.0.0"]
|
|
25
|
+
build-backend = "poetry.core.masonry.api"
|
gmsg-0.1.4/PKG-INFO
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: gmsg
|
|
3
|
-
Version: 0.1.4
|
|
4
|
-
Summary: Generates git commit messages for you using AI.
|
|
5
|
-
License: MIT
|
|
6
|
-
Author: shiyan99s@gmail.com
|
|
7
|
-
Requires-Python: >=3.9
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Requires-Dist: google-genai (>=1.9.0,<2.0.0)
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
|
|
18
|
-
|
gmsg-0.1.4/README.md
DELETED
|
File without changes
|
gmsg-0.1.4/pyproject.toml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "gmsg"
|
|
3
|
-
version = "0.1.4"
|
|
4
|
-
description = "Generates git commit messages for you using AI."
|
|
5
|
-
authors = [
|
|
6
|
-
{name = "shiyan99s@gmail.com"}
|
|
7
|
-
]
|
|
8
|
-
license = {text = "MIT"}
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.9"
|
|
11
|
-
dependencies = [
|
|
12
|
-
"google-genai (>=1.9.0,<2.0.0)"
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
[project.scripts]
|
|
16
|
-
gmsg = "gmsg.gmsg:main"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[build-system]
|
|
20
|
-
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
21
|
-
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|