gmsg 0.1.5__tar.gz → 0.1.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.
gmsg-0.1.7/PKG-INFO ADDED
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.3
2
+ Name: gmsg
3
+ Version: 0.1.7
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
+
@@ -35,7 +35,7 @@ Get your [Google Gemini API key](https://aistudio.google.com/app/apikey) if you
35
35
  Enter your api key when package is used for the first time.
36
36
 
37
37
  ```bash
38
- $ ENTER your API Key=
38
+ $ Enter your Gemini API KEY:
39
39
  ```
40
40
 
41
41
  ---
@@ -83,13 +83,14 @@ Message committed to git. You can run `git commit --amend` to modify it.
83
83
  ## 🧩 Requirements
84
84
 
85
85
  * Python 3.10+
86
- * [Google Generative AI SDK](https://pypi.org/project/google-generativeai/)
87
86
  * Git installed and available in your system path
88
87
  ---
89
88
 
90
89
  ## 📍 Roadmap
91
90
 
92
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.
93
94
 
94
95
  * [ ] **CLI Arguments Support**
95
96
  Add flags like `--dry-run` for non-interactive use.
@@ -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 = input("Enter your Gemini API KEY: ").strip()
15
- with open(rc, 'w') as f:
16
- f.write(key_inp)
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, 'r') as f:
21
+ with open(rc, "r") as f:
21
22
  return f.read().strip()
22
23
  except KeyboardInterrupt:
23
24
  sys.exit(0)
@@ -5,6 +5,7 @@ import subprocess
5
5
  from google import genai
6
6
  from pathlib import Path
7
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(dict(error="Gemini API key not valid, check ~/.gmsg"),
51
+ printt("Gemini API key is invalid, check ~/.gmsg",
51
52
  is_success=False)
53
+ sys.exit(1)
52
54
  else:
53
- printt(error, is_success=False)
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? [Y = yes / e = edit / n = no]: "
66
+ "Do you want to continue with this message? c(continue) / e(edit) / r(regenerate) / a(abort): "
65
67
  ).strip().lower()
66
- if action in ("", "y", "Y"):
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 in ("n", "N"):
75
+ elif action == "r":
74
76
  msg = trigger_query(query, api_key)
75
- elif action in ("e", "E"):
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("Invalid input. Please enter 'Y', 'e', or 'n'.")
82
+ print("warning: invalid input")
80
83
 
81
84
 
82
85
  def commit_message_to_git(generated_msg: str) -> str | None:
@@ -120,12 +123,12 @@ def main():
120
123
  try:
121
124
  user_api_key = get_or_set_api_key()
122
125
  if not is_git_repo():
123
- printt("Not a git repository.", is_success=False)
126
+ printt("warning: not a git repository.", is_success=False)
124
127
  sys.exit(1)
125
128
 
126
129
  diff = git_diff()
127
130
  if not diff:
128
- printt("No staged changes found.", is_success=False)
131
+ printt("warning: no staged changes found", is_success=False)
129
132
  sys.exit(1)
130
133
 
131
134
  cycle_through_messages(diff, user_api_key)
@@ -0,0 +1,25 @@
1
+ [tool.poetry]
2
+ name = "gmsg"
3
+ version = "0.1.7"
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.5/PKG-INFO DELETED
@@ -1,18 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: gmsg
3
- Version: 0.1.5
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.5/README.md DELETED
File without changes
gmsg-0.1.5/pyproject.toml DELETED
@@ -1,21 +0,0 @@
1
- [project]
2
- name = "gmsg"
3
- version = "0.1.5"
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