git-copilot-commit 0.1.18__tar.gz → 0.1.19__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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-copilot-commit
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: Automatically generate and commit changes using copilot
5
5
  Author-email: Dheepak Krishnamurthy <1813121+kdheepak@users.noreply.github.com>
6
6
  License-File: LICENSE
7
7
  Requires-Python: >=3.12
8
8
  Requires-Dist: platformdirs>=4.0.0
9
- Requires-Dist: pycopilot>=0.1.6
9
+ Requires-Dist: pycopilot>=0.1.7
10
10
  Requires-Dist: rich>=14.0.0
11
11
  Requires-Dist: typer>=0.16.0
12
12
  Description-Content-Type: text/markdown
@@ -38,7 +38,14 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
38
38
  powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
39
39
  ```
40
40
 
41
- Then install and run `git-copilot-commit`:
41
+ You can install and run the latest version of tool directly every time by invoking this one command:
42
+
43
+ ```bash
44
+ # Install latest version into temporary environment and run --help
45
+ uvx git-copilot-commit --help
46
+ ```
47
+
48
+ Alternatively, you can install into a global isolated environment and run `git-copilot-commit`:
42
49
 
43
50
  ```bash
44
51
  # Install into global isolated environment
@@ -48,14 +55,6 @@ uv tool install git-copilot-commit
48
55
  git-copilot-commit --help
49
56
  ```
50
57
 
51
- Alternatively, you can install and run the latest version of tool directly every time by invoking
52
- this one command:
53
-
54
- ```bash
55
- # Install latest version into temporary environment and run --help
56
- uvx git-copilot-commit --help
57
- ```
58
-
59
58
  [`uv`]: https://github.com/astral-sh/uv
60
59
 
61
60
  ### Install with `pipx`
@@ -75,7 +74,7 @@ pipx install git-copilot-commit
75
74
  1. Authenticate with GitHub Copilot:
76
75
 
77
76
  ```bash
78
- git-copilot-commit authenticate
77
+ uvx git-copilot-commit authenticate
79
78
  ```
80
79
 
81
80
  2. Make changes in your repository.
@@ -83,9 +82,9 @@ pipx install git-copilot-commit
83
82
  3. Generate and commit:
84
83
 
85
84
  ```bash
86
- git-copilot-commit commit
85
+ uvx git-copilot-commit commit
87
86
  # Or, if you want to stage all files and accept the generated commit message, use:
88
- git-copilot-commit commit --all --yes
87
+ uvx git-copilot-commit commit --all --yes
89
88
  ```
90
89
 
91
90
  ## Usage
@@ -148,27 +147,27 @@ Options:
148
147
  Commit all changes:
149
148
 
150
149
  ```bash
151
- git-copilot-commit commit --all
150
+ uvx git-copilot-commit commit --all
152
151
  ```
153
152
 
154
153
  Accept the generated commit message without editing:
155
154
 
156
155
  ```bash
157
- git-copilot-commit commit --yes
156
+ uvx git-copilot-commit commit --yes
158
157
  ```
159
158
 
160
159
  Use a specific model:
161
160
 
162
161
  ```bash
163
- git-copilot-commit commit --model claude-3.5-sonnet
162
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
164
163
  ```
165
164
 
166
165
  Set and use a default model:
167
166
 
168
167
  ```bash
169
- git-copilot-commit config --set-default-model gpt-4o
170
- git-copilot-commit commit
171
- git-copilot-commit commit --model claude-3.5-sonnet
168
+ uvx git-copilot-commit config --set-default-model gpt-4o
169
+ uvx git-copilot-commit commit
170
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
172
171
  ```
173
172
 
174
173
  ## Commit Message Format
@@ -25,7 +25,14 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
25
25
  powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
26
26
  ```
27
27
 
28
- Then install and run `git-copilot-commit`:
28
+ You can install and run the latest version of tool directly every time by invoking this one command:
29
+
30
+ ```bash
31
+ # Install latest version into temporary environment and run --help
32
+ uvx git-copilot-commit --help
33
+ ```
34
+
35
+ Alternatively, you can install into a global isolated environment and run `git-copilot-commit`:
29
36
 
30
37
  ```bash
31
38
  # Install into global isolated environment
@@ -35,14 +42,6 @@ uv tool install git-copilot-commit
35
42
  git-copilot-commit --help
36
43
  ```
37
44
 
38
- Alternatively, you can install and run the latest version of tool directly every time by invoking
39
- this one command:
40
-
41
- ```bash
42
- # Install latest version into temporary environment and run --help
43
- uvx git-copilot-commit --help
44
- ```
45
-
46
45
  [`uv`]: https://github.com/astral-sh/uv
47
46
 
48
47
  ### Install with `pipx`
@@ -62,7 +61,7 @@ pipx install git-copilot-commit
62
61
  1. Authenticate with GitHub Copilot:
63
62
 
64
63
  ```bash
65
- git-copilot-commit authenticate
64
+ uvx git-copilot-commit authenticate
66
65
  ```
67
66
 
68
67
  2. Make changes in your repository.
@@ -70,9 +69,9 @@ pipx install git-copilot-commit
70
69
  3. Generate and commit:
71
70
 
72
71
  ```bash
73
- git-copilot-commit commit
72
+ uvx git-copilot-commit commit
74
73
  # Or, if you want to stage all files and accept the generated commit message, use:
75
- git-copilot-commit commit --all --yes
74
+ uvx git-copilot-commit commit --all --yes
76
75
  ```
77
76
 
78
77
  ## Usage
@@ -135,27 +134,27 @@ Options:
135
134
  Commit all changes:
136
135
 
137
136
  ```bash
138
- git-copilot-commit commit --all
137
+ uvx git-copilot-commit commit --all
139
138
  ```
140
139
 
141
140
  Accept the generated commit message without editing:
142
141
 
143
142
  ```bash
144
- git-copilot-commit commit --yes
143
+ uvx git-copilot-commit commit --yes
145
144
  ```
146
145
 
147
146
  Use a specific model:
148
147
 
149
148
  ```bash
150
- git-copilot-commit commit --model claude-3.5-sonnet
149
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
151
150
  ```
152
151
 
153
152
  Set and use a default model:
154
153
 
155
154
  ```bash
156
- git-copilot-commit config --set-default-model gpt-4o
157
- git-copilot-commit commit
158
- git-copilot-commit commit --model claude-3.5-sonnet
155
+ uvx git-copilot-commit config --set-default-model gpt-4o
156
+ uvx git-copilot-commit commit
157
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
159
158
  ```
160
159
 
161
160
  ## Commit Message Format
@@ -8,7 +8,7 @@ authors = [
8
8
  ]
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
11
- "pycopilot>=0.1.6",
11
+ "pycopilot>=0.1.7",
12
12
  "rich>=14.0.0",
13
13
  "typer>=0.16.0",
14
14
  "platformdirs>=4.0.0",
@@ -2,6 +2,7 @@
2
2
  git-copilot-commit - AI-powered Git commit assistant
3
3
  """
4
4
 
5
+ import rich.terminal_theme
5
6
  import typer
6
7
  from rich.console import Console
7
8
  from rich.prompt import Confirm
@@ -10,7 +11,7 @@ from rich.table import Table
10
11
  import rich
11
12
  from pathlib import Path
12
13
 
13
- from pycopilot.copilot import Copilot # type: ignore
14
+ from pycopilot.copilot import Copilot, CopilotAPIError # type: ignore
14
15
  from pycopilot.auth import Authentication
15
16
  from .git import GitRepository, GitError, NotAGitRepositoryError, GitStatus
16
17
  from .settings import Settings
@@ -40,17 +41,23 @@ def main(
40
41
  # Show help when no command is provided
41
42
  print(ctx.get_help())
42
43
  raise typer.Exit()
44
+ else:
45
+ console.print(
46
+ f"[bold]{(__package__ or 'git_copilot_commit').replace('_', '-')}[/] - [bold blue]v{__version__}[/]\n"
47
+ )
43
48
 
44
49
 
45
50
  def get_prompt_locations():
46
51
  """Get potential prompt file locations in order of preference."""
47
52
  import importlib.resources
48
-
53
+
49
54
  filename = "commit-message-generator-prompt.md"
50
-
55
+
51
56
  return [
52
57
  Path(Settings().data_dir) / "prompts" / filename, # User customizable
53
- importlib.resources.files("git_copilot_commit") / "prompts" / filename # Packaged version
58
+ importlib.resources.files("git_copilot_commit")
59
+ / "prompts"
60
+ / filename, # Packaged version
54
61
  ]
55
62
 
56
63
 
@@ -72,7 +79,7 @@ def load_system_prompt() -> str:
72
79
  return path.read_text(encoding="utf-8")
73
80
  except (FileNotFoundError, AttributeError):
74
81
  continue
75
-
82
+
76
83
  console.print("[red]Error: Prompt file not found in any location[/red]")
77
84
  raise typer.Exit(1)
78
85
 
@@ -82,21 +89,10 @@ def generate_commit_message(
82
89
  ) -> str:
83
90
  """Generate a conventional commit message using Copilot API."""
84
91
 
85
- # Get recent commits for context (handle empty repositories)
86
- try:
87
- recent_commits = repo.get_recent_commits(limit=5)
88
- recent_commits_text = "\n".join([f"- {msg}" for _, msg in recent_commits])
89
- except GitError:
90
- # No commits yet in this repository
91
- recent_commits_text = "No previous commits (initial commit)"
92
-
93
92
  system_prompt = load_system_prompt()
94
93
  client = Copilot(system_prompt=system_prompt)
95
94
 
96
- prompt = f"""Recent commits:
97
-
98
- {recent_commits_text}
99
-
95
+ prompt = f"""
100
96
  `git status`:
101
97
 
102
98
  ```
@@ -111,8 +107,25 @@ def generate_commit_message(
111
107
 
112
108
  Generate a conventional commit message:"""
113
109
 
114
- response = client.ask(prompt, model=model) if model else client.ask(prompt)
115
- return response.content
110
+ try:
111
+ response = client.ask(prompt, model=model) if model else client.ask(prompt)
112
+ return response.content
113
+ except CopilotAPIError:
114
+ # Fallback to git status only when diff is too large
115
+ fallback_prompt = f"""`git status`:
116
+
117
+ ```
118
+ {status.get_porcelain_output()}
119
+ ```
120
+
121
+ Generate a conventional commit message based on the git status above:"""
122
+
123
+ response = (
124
+ client.ask(fallback_prompt, model=model)
125
+ if model
126
+ else client.ask(fallback_prompt)
127
+ )
128
+ return response.content
116
129
 
117
130
 
118
131
  @app.command()
@@ -68,7 +68,7 @@ dependencies = [
68
68
  [package.metadata]
69
69
  requires-dist = [
70
70
  { name = "platformdirs", specifier = ">=4.0.0" },
71
- { name = "pycopilot", specifier = ">=0.1.6" },
71
+ { name = "pycopilot", specifier = ">=0.1.7" },
72
72
  { name = "rich", specifier = ">=14.0.0" },
73
73
  { name = "typer", specifier = ">=0.16.0" },
74
74
  ]
@@ -163,7 +163,7 @@ wheels = [
163
163
 
164
164
  [[package]]
165
165
  name = "pycopilot"
166
- version = "0.1.6"
166
+ version = "0.1.7"
167
167
  source = { registry = "https://pypi.org/simple" }
168
168
  dependencies = [
169
169
  { name = "httpx" },
@@ -174,9 +174,9 @@ dependencies = [
174
174
  { name = "rich" },
175
175
  { name = "typer" },
176
176
  ]
177
- sdist = { url = "https://files.pythonhosted.org/packages/45/ae/9d540cfe9411ad9f5ab58080aab86a5a7902ab668ad16fb637f287c88ba7/pycopilot-0.1.6.tar.gz", hash = "sha256:84425265e0d587d964e7b5dd93de9d9175b849b7d718107a48efb749e5b88e8e", size = 31667, upload-time = "2025-07-17T15:39:42.473Z" }
177
+ sdist = { url = "https://files.pythonhosted.org/packages/41/c9/666fe6cefc806e363674b619c3d79575f3966474a77b828af2f9a725d7c8/pycopilot-0.1.7.tar.gz", hash = "sha256:82e295ef7fa6e9d626d12183adc8786ee6baa30f77e582d6a2f712cd88b69193", size = 31866, upload-time = "2025-07-22T12:25:14.553Z" }
178
178
  wheels = [
179
- { url = "https://files.pythonhosted.org/packages/3e/5f/56cd35579f5d400b2ef9f0c62b41f6024936fbfc8f69e302036588052531/pycopilot-0.1.6-py3-none-any.whl", hash = "sha256:88f39535a87d1efdc2358357d956bbe0d9e6b5a6fd60d572d46c813fe23af2d0", size = 10811, upload-time = "2025-07-17T15:39:41.608Z" },
179
+ { url = "https://files.pythonhosted.org/packages/1a/fb/401f2395f2051c2e1d0b997a5ad355310ecdfdc68b06718554971280b18d/pycopilot-0.1.7-py3-none-any.whl", hash = "sha256:9fced5efcfab9d0b91d2d542e4949e17f32f395f27b529882af0200908cfb9cc", size = 10930, upload-time = "2025-07-22T12:25:13.513Z" },
180
180
  ]
181
181
 
182
182
  [[package]]