gmsg 0.1.5__py3-none-any.whl → 0.1.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.
gmsg/api_key.py CHANGED
@@ -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)
gmsg/gmsg.py CHANGED
@@ -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(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)
@@ -1,3 +1,22 @@
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
+
1
20
  # gmsg
2
21
 
3
22
  A command-line tool that automatically generates concise and meaningful Git commit messages using Google's Gemini model based on your staged changes.
@@ -35,7 +54,7 @@ Get your [Google Gemini API key](https://aistudio.google.com/app/apikey) if you
35
54
  Enter your api key when package is used for the first time.
36
55
 
37
56
  ```bash
38
- $ ENTER your API Key=
57
+ $ Enter your Gemini API KEY:
39
58
  ```
40
59
 
41
60
  ---
@@ -83,13 +102,14 @@ Message committed to git. You can run `git commit --amend` to modify it.
83
102
  ## 🧩 Requirements
84
103
 
85
104
  * Python 3.10+
86
- * [Google Generative AI SDK](https://pypi.org/project/google-generativeai/)
87
105
  * Git installed and available in your system path
88
106
  ---
89
107
 
90
108
  ## 📍 Roadmap
91
109
 
92
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.
93
113
 
94
114
  * [ ] **CLI Arguments Support**
95
115
  Add flags like `--dry-run` for non-interactive use.
@@ -119,3 +139,4 @@ MIT License. Feel free to use, modify, and contribute!
119
139
 
120
140
  Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
121
141
 
142
+
@@ -0,0 +1,8 @@
1
+ gmsg/__init__.py,sha256=9B4ZkbOBiBYYqv3Kh-mdlNn-yDPvkpXOqrm52Ng8CTk,23
2
+ gmsg/api_key.py,sha256=96bDUpVDZaFqT7_CRRuiQ7G39ZHatLWRBwCxNDXjxq8,600
3
+ gmsg/gmsg.py,sha256=EtODFTmoRJxUJ-hA6M7bPh_VSMgrW-N6X1ABXUJcAZw,3978
4
+ gmsg-0.1.6.dist-info/LICENSE,sha256=4gnFnu1ft89RQUn-ohdbqKLhpQ6-wHtq2eAOs1p6X6M,1071
5
+ gmsg-0.1.6.dist-info/METADATA,sha256=Ab4vV66zEF8YWU44nu2JPaK4WounQZFGIZLf2SGhoeM,3370
6
+ gmsg-0.1.6.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
7
+ gmsg-0.1.6.dist-info/entry_points.txt,sha256=LqLzIXT9IVenl_xEptCn4LqWHm34ypTaVMhoW5tFBSg,39
8
+ gmsg-0.1.6.dist-info/RECORD,,
@@ -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
-
@@ -1,9 +0,0 @@
1
- gmsg/README.md,sha256=r08M-p_W2PtDdAEoapaqRCWZAKBbDCjYOEzE7CsNoKY,2676
2
- gmsg/__init__.py,sha256=9B4ZkbOBiBYYqv3Kh-mdlNn-yDPvkpXOqrm52Ng8CTk,23
3
- gmsg/api_key.py,sha256=73RAEjrcN6f1tc3cqaJ5888COTm4gnjQ4G7VRB3-CnQ,569
4
- gmsg/gmsg.py,sha256=SSmIomjS7c6JfWygp6aZApXvzS33qoNRpYuEcO46-mM,3871
5
- gmsg-0.1.5.dist-info/LICENSE,sha256=4gnFnu1ft89RQUn-ohdbqKLhpQ6-wHtq2eAOs1p6X6M,1071
6
- gmsg-0.1.5.dist-info/METADATA,sha256=Ds9Kf8kZJ9Dq4NMZDUU7oV5tNmvL4PappxLaMAWYvTM,609
7
- gmsg-0.1.5.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
8
- gmsg-0.1.5.dist-info/entry_points.txt,sha256=LqLzIXT9IVenl_xEptCn4LqWHm34ypTaVMhoW5tFBSg,39
9
- gmsg-0.1.5.dist-info/RECORD,,
File without changes
File without changes