commitmessagegenerator 1.4.1__tar.gz → 1.6.0__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.
Files changed (17) hide show
  1. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/PKG-INFO +27 -2
  2. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/README.md +26 -1
  3. commitmessagegenerator-1.6.0/commitmessagegenerator/cli.py +78 -0
  4. commitmessagegenerator-1.6.0/commitmessagegenerator/configure.py +47 -0
  5. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator/generator.py +7 -7
  6. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/PKG-INFO +27 -2
  7. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/pyproject.toml +1 -1
  8. commitmessagegenerator-1.4.1/commitmessagegenerator/cli.py +0 -40
  9. commitmessagegenerator-1.4.1/commitmessagegenerator/configure.py +0 -22
  10. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/LICENSE +0 -0
  11. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator/__init__.py +0 -0
  12. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/SOURCES.txt +0 -0
  13. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/dependency_links.txt +0 -0
  14. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/entry_points.txt +0 -0
  15. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/requires.txt +0 -0
  16. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/commitmessagegenerator.egg-info/top_level.txt +0 -0
  17. {commitmessagegenerator-1.4.1 → commitmessagegenerator-1.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commitmessagegenerator
3
- Version: 1.4.1
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
@@ -22,6 +22,11 @@ pip install commitmessagegenerator
22
22
  commitgen -cf
23
23
  ```
24
24
 
25
+ This will prompt you for:
26
+
27
+ 1. Your Gemini API key
28
+ 2. Your preferred AI model (with options to choose from)
29
+
25
30
  ## Run this and type you API key to the terminal so the package creates the .env file and automatically adds it to the .gitignore
26
31
 
27
32
  Or do it manually:
@@ -32,6 +37,7 @@ Create a `.env` file in the directory where you will run commitgen (usually the
32
37
 
33
38
  ```
34
39
  GEMINI_API_KEY=your-gemini-api-key
40
+ AI_MODEL=gemini-2.0-flash
35
41
  ```
36
42
 
37
43
  ## 🚀 Usage
@@ -45,9 +51,28 @@ commitgen (-c/-cp)
45
51
  The command will:
46
52
 
47
53
  - Read the git diff;
48
- - Send it to the Google Gemini API;
54
+ - Send it to the Google Gemini API using your configured model;
49
55
  - Return a commit message suggestion directly in your terminal.
50
56
 
57
+ ### Available Commands
58
+
59
+ - `commitgen` - Generate commit message only
60
+ - `commitgen -c` - Generate and commit with the message
61
+ - `commitgen -cp` - Generate, commit, and push
62
+ - `commitgen -cf` - Configure API key and model
63
+ - `commitgen -s` - Show current configuration status
64
+
65
+ ### Available Models
66
+
67
+ When configuring with `-cf`, you can choose from:
68
+
69
+ 1. **gemini-2.0-flash** (default) - Fast and efficient
70
+ 2. **gemini-1.5-flash** - Good balance of speed and quality
71
+ 3. **gemini-1.5-pro** - Highest quality, slower
72
+ 4. **gemini-2.0-flash-exp** - Experimental version
73
+ 5. **gemini-2.5-flash** - Latest version, fast and efficient
74
+ 6. **gemini-2.5-pro** - Latest version, highest quality
75
+
51
76
  ## 🧩 Requisites
52
77
 
53
78
  - Python 3.8 or higher
@@ -0,0 +1,78 @@
1
+ import argparse
2
+ import subprocess
3
+ from .generator import gerar_mensagem_commit
4
+ from .configure import api_key, get_configured_model
5
+ import sys
6
+ import getpass
7
+
8
+ def main():
9
+ parser = argparse.ArgumentParser(description="Gerador de mensagens de commit com IA")
10
+ parser.add_argument("-c", "--commit", action="store_true", help="Commits with the generated message")
11
+ parser.add_argument("-cp", "--commitpush", action="store_true", help="Commits and pushes with the generated message")
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")
14
+ args = parser.parse_args()
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
+
30
+ if not args.configure:
31
+ mensagem = gerar_mensagem_commit()
32
+
33
+ if "No changes detected" in mensagem:
34
+ print(mensagem)
35
+ return
36
+
37
+ print("\nGenerated commit message:\n" + mensagem)
38
+
39
+ if args.commit or args.commitpush:
40
+ print("\nCommitting changes...")
41
+ subprocess.run(["git", "commit", "-m", mensagem])
42
+
43
+ if args.commitpush:
44
+ print("\nPushing changes...")
45
+ subprocess.run(["git", "push"])
46
+
47
+ if args.configure:
48
+ print("\nPlease input your API KEY\nThis is directly set in the .env file")
49
+ key = getpass.getpass()
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")
75
+
76
+ if len(sys.argv) == 1:
77
+ print("\nRemoving staged changes (git reset)...")
78
+ subprocess.run(["git", "reset"])
@@ -0,0 +1,47 @@
1
+ import os
2
+
3
+ def api_key(key, model="gemini-2.0-flash"):
4
+ if os.path.exists(".env"):
5
+ with open(".env", "r+") as outfile:
6
+ lines = outfile.readlines()
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
14
+ if gemini_api_key:
15
+ outfile.writelines([line if not line.startswith("GEMINI_API_KEY=") else f"GEMINI_API_KEY={key}\n" for line in lines])
16
+ else:
17
+ outfile.writelines(lines)
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")
27
+ else:
28
+ with open(".env", "w") as outfile:
29
+ outfile.write(f"GEMINI_API_KEY={key}\n")
30
+ outfile.write(f"AI_MODEL={model}\n")
31
+
32
+ if os.path.exists(".gitignore"):
33
+ with open(".gitignore", "r+") as outfile:
34
+ lines = outfile.readlines()
35
+ env_in_gitignore = next((line for line in lines if line.strip() == ".env"), None)
36
+ if not env_in_gitignore:
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
 
@@ -38,9 +39,8 @@ def gerar_mensagem_commit():
38
39
  '''
39
40
  )
40
41
 
41
- response = client.generate_content(
42
- model="gemini-2.0-flash",
43
- contents=[{"role": "user", "parts": [prompt]}]
42
+ response = client.models.generate_content(
43
+ model=model,
44
+ contents=prompt
44
45
  )
45
- return response.text.strip()
46
-
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.4.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "commitmessagegenerator"
7
- version = "1.4.1"
7
+ version = "1.6.0"
8
8
  description = "Generate commit messages with AI (Google Gemini) automatically using `git diff`."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -1,40 +0,0 @@
1
- import argparse
2
- import subprocess
3
- from .generator import gerar_mensagem_commit
4
- from .configure import api_key
5
- import sys
6
- import getpass
7
-
8
- def main():
9
- parser = argparse.ArgumentParser(description="Gerador de mensagens de commit com IA")
10
- parser.add_argument("-c", "--commit", action="store_true", help="Commits with the generated message")
11
- parser.add_argument("-cp", "--commitpush", action="store_true", help="Commits and pushes with the generated message")
12
- parser.add_argument("-cf", "--configure", action="store_true", help="Configures the GEMINI_API_KEY environment variable")
13
- args = parser.parse_args()
14
-
15
- if not args.configure:
16
- mensagem = gerar_mensagem_commit()
17
-
18
- if "No changes detected" in mensagem:
19
- print(mensagem)
20
- return
21
-
22
- print("\nGenerated commit message:\n" + mensagem)
23
-
24
- if args.commit or args.commitpush:
25
- print("\nCommitting changes...")
26
- subprocess.run(["git", "commit", "-m", mensagem])
27
-
28
- if args.commitpush:
29
- print("\nPushing changes...")
30
- subprocess.run(["git", "push"])
31
-
32
- if args.configure:
33
- print("\nPlease input your API KEY\nThis is directly set in the .env file")
34
- key = getpass.getpass()
35
- api_key(key)
36
- print("\nAPI KEY saved in .env file\n")
37
-
38
- if len(sys.argv) == 1:
39
- print("\nRemoving staged changes (git reset)...")
40
- subprocess.run(["git", "reset"])
@@ -1,22 +0,0 @@
1
- import os
2
- def api_key(key):
3
- if os.path.exists(".env"):
4
- with open(".env", "r+") as outfile:
5
- lines = outfile.readlines()
6
- gemini_api_key = next((line for line in lines if line.startswith("GEMINI_API_KEY=")), None)
7
- if gemini_api_key:
8
- outfile.seek(0)
9
- outfile.truncate()
10
- outfile.writelines([line if not line.startswith("GEMINI_API_KEY=") else f"GEMINI_API_KEY={key}\n" for line in lines])
11
- else:
12
- outfile.write(f"GEMINI_API_KEY={key}\n")
13
- else:
14
- with open(".env", "w") as outfile:
15
- outfile.write(f"GEMINI_API_KEY={key}\n")
16
-
17
- if os.path.exists(".gitignore"):
18
- with open(".gitignore", "r+") as outfile:
19
- lines = outfile.readlines()
20
- env_in_gitignore = next((line for line in lines if line.strip() == ".env"), None)
21
- if not env_in_gitignore:
22
- outfile.write("\n.env")