commitmessagegenerator 1.5.0__py3-none-any.whl → 1.6.0__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.
@@ -1,7 +1,7 @@
1
1
  import argparse
2
2
  import subprocess
3
3
  from .generator import gerar_mensagem_commit
4
- from .configure import api_key
4
+ from .configure import api_key, get_configured_model
5
5
  import sys
6
6
  import getpass
7
7
 
@@ -10,8 +10,23 @@ def main():
10
10
  parser.add_argument("-c", "--commit", action="store_true", help="Commits with the generated message")
11
11
  parser.add_argument("-cp", "--commitpush", action="store_true", help="Commits and pushes with the generated message")
12
12
  parser.add_argument("-cf", "--configure", action="store_true", help="Configures the GEMINI_API_KEY environment variable")
13
+ parser.add_argument("-s", "--status", action="store_true", help="Shows current configuration status")
13
14
  args = parser.parse_args()
14
15
 
16
+ if args.status:
17
+ from .configure import get_configured_model
18
+ import os
19
+ from dotenv import load_dotenv
20
+
21
+ load_dotenv()
22
+ key = os.getenv("GEMINI_API_KEY")
23
+ model = get_configured_model()
24
+
25
+ print("\nCurrent Configuration:")
26
+ print(f"API Key: {'✓ Set' if key else '✗ Not set'}")
27
+ print(f"Model: {model}")
28
+ return
29
+
15
30
  if not args.configure:
16
31
  mensagem = gerar_mensagem_commit()
17
32
 
@@ -32,8 +47,31 @@ def main():
32
47
  if args.configure:
33
48
  print("\nPlease input your API KEY\nThis is directly set in the .env file")
34
49
  key = getpass.getpass()
35
- api_key(key)
36
- print("\nAPI KEY saved in .env file\n")
50
+
51
+ # Model selection
52
+ print("\nAvailable models:")
53
+ print("1. gemini-2.0-flash (default, fast and efficient)")
54
+ print("2. gemini-1.5-flash (good balance of speed and quality)")
55
+ print("3. gemini-1.5-pro (highest quality, slower)")
56
+ print("4. gemini-2.0-flash-exp (experimental)")
57
+ print("5. gemini-2.5-flash (latest, fast and efficient)")
58
+ print("6. gemini-2.5-pro (latest, highest quality)")
59
+
60
+ model_choice = input("\nSelect model (1-6) or press Enter for default (1): ").strip()
61
+
62
+ model_map = {
63
+ "1": "gemini-2.0-flash",
64
+ "2": "gemini-1.5-flash",
65
+ "3": "gemini-1.5-pro",
66
+ "4": "gemini-2.0-flash-exp",
67
+ "5": "gemini-2.5-flash",
68
+ "6": "gemini-2.5-pro"
69
+ }
70
+
71
+ selected_model = model_map.get(model_choice, "gemini-2.0-flash")
72
+
73
+ api_key(key, selected_model)
74
+ print(f"\nAPI KEY and model ({selected_model}) saved in .env file\n")
37
75
 
38
76
  if len(sys.argv) == 1:
39
77
  print("\nRemoving staged changes (git reset)...")
@@ -1,18 +1,33 @@
1
1
  import os
2
- def api_key(key):
2
+
3
+ def api_key(key, model="gemini-2.0-flash"):
3
4
  if os.path.exists(".env"):
4
5
  with open(".env", "r+") as outfile:
5
6
  lines = outfile.readlines()
6
7
  gemini_api_key = next((line for line in lines if line.startswith("GEMINI_API_KEY=")), None)
8
+ model_line = next((line for line in lines if line.startswith("AI_MODEL=")), None)
9
+
10
+ outfile.seek(0)
11
+ outfile.truncate()
12
+
13
+ # Update or add GEMINI_API_KEY
7
14
  if gemini_api_key:
8
- outfile.seek(0)
9
- outfile.truncate()
10
15
  outfile.writelines([line if not line.startswith("GEMINI_API_KEY=") else f"GEMINI_API_KEY={key}\n" for line in lines])
11
16
  else:
17
+ outfile.writelines(lines)
12
18
  outfile.write(f"GEMINI_API_KEY={key}\n")
19
+
20
+ # Update or add AI_MODEL
21
+ if model_line:
22
+ outfile.seek(0)
23
+ outfile.truncate()
24
+ outfile.writelines([line if not line.startswith("AI_MODEL=") else f"AI_MODEL={model}\n" for line in outfile.readlines()])
25
+ else:
26
+ outfile.write(f"AI_MODEL={model}\n")
13
27
  else:
14
28
  with open(".env", "w") as outfile:
15
29
  outfile.write(f"GEMINI_API_KEY={key}\n")
30
+ outfile.write(f"AI_MODEL={model}\n")
16
31
 
17
32
  if os.path.exists(".gitignore"):
18
33
  with open(".gitignore", "r+") as outfile:
@@ -20,3 +35,13 @@ def api_key(key):
20
35
  env_in_gitignore = next((line for line in lines if line.strip() == ".env"), None)
21
36
  if not env_in_gitignore:
22
37
  outfile.write("\n.env")
38
+
39
+ def get_configured_model():
40
+ """Get the currently configured AI model from .env file"""
41
+ if os.path.exists(".env"):
42
+ with open(".env", "r") as outfile:
43
+ lines = outfile.readlines()
44
+ model_line = next((line for line in lines if line.startswith("AI_MODEL=")), None)
45
+ if model_line:
46
+ return model_line.split("=", 1)[1].strip()
47
+ return "gemini-2.0-flash" # Default fallback
@@ -2,6 +2,7 @@ import os
2
2
  from dotenv import load_dotenv
3
3
  from google import genai
4
4
  from git import Repo
5
+ from .configure import get_configured_model
5
6
 
6
7
  def gerar_mensagem_commit():
7
8
  load_dotenv()
@@ -9,8 +10,8 @@ def gerar_mensagem_commit():
9
10
  if not key:
10
11
  raise RuntimeError("The GEMINI_API_KEY environment variable is not set.")
11
12
 
12
- #genai.configure(api_key=key)
13
- #model = genai.GenerativeModel("gemini-2.0-flash")
13
+ # Get the configured model
14
+ model = get_configured_model()
14
15
 
15
16
  client = genai.Client(api_key=key)
16
17
 
@@ -39,7 +40,7 @@ def gerar_mensagem_commit():
39
40
  )
40
41
 
41
42
  response = client.models.generate_content(
42
- model="gemini-2.0-flash",
43
+ model=model,
43
44
  contents=prompt
44
45
  )
45
- return response.text.strip()
46
+ return response.text.strip() if response.text else "Failed to generate commit message"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commitmessagegenerator
3
- Version: 1.5.0
3
+ Version: 1.6.0
4
4
  Summary: Generate commit messages with AI (Google Gemini) automatically using `git diff`.
5
5
  Author-email: Gabriel Terceiro <gcarolinoterceiro@gmail.com>
6
6
  License: MIT
@@ -35,6 +35,11 @@ pip install commitmessagegenerator
35
35
  commitgen -cf
36
36
  ```
37
37
 
38
+ This will prompt you for:
39
+
40
+ 1. Your Gemini API key
41
+ 2. Your preferred AI model (with options to choose from)
42
+
38
43
  ## Run this and type you API key to the terminal so the package creates the .env file and automatically adds it to the .gitignore
39
44
 
40
45
  Or do it manually:
@@ -45,6 +50,7 @@ Create a `.env` file in the directory where you will run commitgen (usually the
45
50
 
46
51
  ```
47
52
  GEMINI_API_KEY=your-gemini-api-key
53
+ AI_MODEL=gemini-2.0-flash
48
54
  ```
49
55
 
50
56
  ## 🚀 Usage
@@ -58,9 +64,28 @@ commitgen (-c/-cp)
58
64
  The command will:
59
65
 
60
66
  - Read the git diff;
61
- - Send it to the Google Gemini API;
67
+ - Send it to the Google Gemini API using your configured model;
62
68
  - Return a commit message suggestion directly in your terminal.
63
69
 
70
+ ### Available Commands
71
+
72
+ - `commitgen` - Generate commit message only
73
+ - `commitgen -c` - Generate and commit with the message
74
+ - `commitgen -cp` - Generate, commit, and push
75
+ - `commitgen -cf` - Configure API key and model
76
+ - `commitgen -s` - Show current configuration status
77
+
78
+ ### Available Models
79
+
80
+ When configuring with `-cf`, you can choose from:
81
+
82
+ 1. **gemini-2.0-flash** (default) - Fast and efficient
83
+ 2. **gemini-1.5-flash** - Good balance of speed and quality
84
+ 3. **gemini-1.5-pro** - Highest quality, slower
85
+ 4. **gemini-2.0-flash-exp** - Experimental version
86
+ 5. **gemini-2.5-flash** - Latest version, fast and efficient
87
+ 6. **gemini-2.5-pro** - Latest version, highest quality
88
+
64
89
  ## 🧩 Requisites
65
90
 
66
91
  - Python 3.8 or higher
@@ -0,0 +1,10 @@
1
+ commitmessagegenerator/__init__.py,sha256=Wsl1vaSI5fWuK3B9MfZnPp1PxnRfTmnvW_20vgswgT0,45
2
+ commitmessagegenerator/cli.py,sha256=7QjfbOv2DWzlQP7eCkFzsX0EI1hc9rKWuGIMjdPv6jM,3006
3
+ commitmessagegenerator/configure.py,sha256=chWBYqPtf4pIdRM9X5VPfjhdhRXVPqrHthdKVFaEBcQ,2068
4
+ commitmessagegenerator/generator.py,sha256=Lrw78EC_s6lfwrrSxJaeK8BJKi2gUgjob7Ms9X70V9g,1519
5
+ commitmessagegenerator-1.6.0.dist-info/licenses/LICENSE,sha256=q7KJbcPCqUAvkBuI1QNc8Kg9XPfBfnNkLN9WKwudO8U,11
6
+ commitmessagegenerator-1.6.0.dist-info/METADATA,sha256=99_RVdKcu_8ewRYSmFgmNBZ3dho2NQTCKbHmTX4mdso,2775
7
+ commitmessagegenerator-1.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ commitmessagegenerator-1.6.0.dist-info/entry_points.txt,sha256=VmVQY00e0SuHsTFZmOCcyN0VYCQlVnZrdZNJdUGLCVo,62
9
+ commitmessagegenerator-1.6.0.dist-info/top_level.txt,sha256=G8wUZw8MTtvYs1WgehFVTPKqw5Td7gGedZZIQbZH1Co,23
10
+ commitmessagegenerator-1.6.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- commitmessagegenerator/__init__.py,sha256=Wsl1vaSI5fWuK3B9MfZnPp1PxnRfTmnvW_20vgswgT0,45
2
- commitmessagegenerator/cli.py,sha256=lpYpRpjcKY6dQ2uhm6Rwpos_lEy9RELhuvE6aSI2jxI,1475
3
- commitmessagegenerator/configure.py,sha256=gzG9cp4B4qIXsoGVTSq-D80N6cmf_A77W73s0k-JkyQ,981
4
- commitmessagegenerator/generator.py,sha256=4BJHi7Perllkxnqf00KWPTQTPh1oZZABX3DXHrApF1Y,1453
5
- commitmessagegenerator-1.5.0.dist-info/licenses/LICENSE,sha256=q7KJbcPCqUAvkBuI1QNc8Kg9XPfBfnNkLN9WKwudO8U,11
6
- commitmessagegenerator-1.5.0.dist-info/METADATA,sha256=TTMjszdGCBBNgRtdGYH5zYT2MEje1PgkieiEAiX5yaE,1909
7
- commitmessagegenerator-1.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- commitmessagegenerator-1.5.0.dist-info/entry_points.txt,sha256=VmVQY00e0SuHsTFZmOCcyN0VYCQlVnZrdZNJdUGLCVo,62
9
- commitmessagegenerator-1.5.0.dist-info/top_level.txt,sha256=G8wUZw8MTtvYs1WgehFVTPKqw5Td7gGedZZIQbZH1Co,23
10
- commitmessagegenerator-1.5.0.dist-info/RECORD,,