git-copilot-commit 0.1.9__tar.gz → 0.1.11__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-copilot-commit
3
- Version: 0.1.9
3
+ Version: 0.1.11
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
@@ -15,7 +15,7 @@ Description-Content-Type: text/markdown
15
15
 
16
16
  AI-powered Git commit assistant that generates conventional commit messages using GitHub Copilot.
17
17
 
18
- ![](https://github.com/user-attachments/assets/6a6d70a6-6060-44e6-8cf4-a6532e9e9142)
18
+ ![Screenshot of git-copilot-commit in action](https://github.com/user-attachments/assets/6a6d70a6-6060-44e6-8cf4-a6532e9e9142)
19
19
 
20
20
  ## Features
21
21
 
@@ -26,26 +26,49 @@ AI-powered Git commit assistant that generates conventional commit messages usin
26
26
 
27
27
  ## Installation
28
28
 
29
- Install with [`uv`] (recommended):
29
+ ### Install the tool using [`uv`] (recommended)
30
+
31
+ Install [`uv`]:
30
32
 
31
33
  ```bash
34
+ # On macOS and Linux.
35
+ curl -LsSf https://astral.sh/uv/install.sh | sh
36
+
37
+ # On Windows.
38
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
39
+ ```
40
+
41
+ Then install `git-copilot-commit`:
42
+
43
+ ```bash
44
+ # Install into isolated environment.
32
45
  uv tool install git-copilot-commit
33
46
  ```
34
47
 
35
- Or with `pipx`:
48
+ Run the tool using:
36
49
 
37
50
  ```bash
38
- pipx install git-copilot-commit
51
+ git-copilot-commit --help
39
52
  ```
40
53
 
41
- Or run directly with [`uv`]:
54
+ Alternatively, you can always install and run the latest version of tool directly in one command by
55
+ using:
42
56
 
43
57
  ```bash
58
+ # Install latest version into temporary environment and run
44
59
  uvx git-copilot-commit --help
45
60
  ```
46
61
 
47
62
  [`uv`]: https://github.com/astral-sh/uv
48
63
 
64
+ ### Install with `pipx`
65
+
66
+ If you prefer to use `pipx`:
67
+
68
+ ```bash
69
+ pipx install git-copilot-commit
70
+ ```
71
+
49
72
  ## Prerequisites
50
73
 
51
74
  - Active GitHub Copilot subscription
@@ -54,17 +77,23 @@ uvx git-copilot-commit --help
54
77
 
55
78
  1. Authenticate with GitHub Copilot:
56
79
 
57
- ```bash
58
- git-copilot-commit authenticate
59
- ```
80
+ ```bash
81
+ git-copilot-commit authenticate
82
+ ```
60
83
 
61
84
  2. Make changes in your repository.
62
85
 
63
86
  3. Generate and commit:
64
87
 
65
- ```bash
66
- git-copilot-commit commit
67
- ```
88
+ ```bash
89
+ git-copilot-commit commit
90
+ ```
91
+
92
+ 4. Or, if you want to stage all files before committing use:
93
+
94
+ ```bash
95
+ git-copilot-commit commit --all
96
+ ```
68
97
 
69
98
  ## Usage
70
99
 
@@ -101,7 +130,7 @@ Options:
101
130
  $ uvx git-copilot-commit models --help
102
131
  Usage: git-copilot-commit models [OPTIONS]
103
132
 
104
- List models available for chat in a Rich table.
133
+ List models available for chat in a table.
105
134
 
106
135
  Options:
107
136
  --help Show this message and exit.
@@ -153,7 +182,7 @@ git-copilot-commit commit --model claude-3.5-sonnet
153
182
 
154
183
  Follows [Conventional Commits](https://www.conventionalcommits.org/):
155
184
 
156
- ```
185
+ ```plaintext
157
186
  <type>[optional scope]: <description>
158
187
  ```
159
188
 
@@ -169,31 +198,24 @@ Follows [Conventional Commits](https://www.conventionalcommits.org/):
169
198
  - `chore`: Maintenance
170
199
  - `revert`: Revert changes
171
200
 
172
- **Examples:**
173
-
174
- - `feat(auth): add JWT authentication`
175
- - `fix(db): retry connection on failure`
176
- - `docs(readme): update install steps`
177
- - `refactor(utils): simplify date parsing`
178
-
179
201
  ## Git Configuration
180
202
 
181
203
  Add a git alias by adding the following to your `~/.gitconfig`:
182
204
 
183
205
  ```ini
184
206
  [alias]
185
- ai-commit = "!f() { git-copilot-commit commit $@; }; f"
207
+ ai-commit = "!f() { uvx git-copilot-commit commit $@; }; f"
186
208
  ```
187
209
 
188
210
  Now you can run:
189
211
 
190
212
  ```bash
191
213
  git ai-commit
192
- git ai-commit --model claude-3.5-sonnet
193
214
  git ai-commit --all --verbose
215
+ git ai-commit --model claude-3.5-sonnet
194
216
  ```
195
217
 
196
- Show more context in diffs:
218
+ Additionally, show more context in diffs by running the following command:
197
219
 
198
220
  ```bash
199
221
  git config --global diff.context 3
@@ -2,7 +2,7 @@
2
2
 
3
3
  AI-powered Git commit assistant that generates conventional commit messages using GitHub Copilot.
4
4
 
5
- ![](https://github.com/user-attachments/assets/6a6d70a6-6060-44e6-8cf4-a6532e9e9142)
5
+ ![Screenshot of git-copilot-commit in action](https://github.com/user-attachments/assets/6a6d70a6-6060-44e6-8cf4-a6532e9e9142)
6
6
 
7
7
  ## Features
8
8
 
@@ -13,26 +13,49 @@ AI-powered Git commit assistant that generates conventional commit messages usin
13
13
 
14
14
  ## Installation
15
15
 
16
- Install with [`uv`] (recommended):
16
+ ### Install the tool using [`uv`] (recommended)
17
+
18
+ Install [`uv`]:
17
19
 
18
20
  ```bash
21
+ # On macOS and Linux.
22
+ curl -LsSf https://astral.sh/uv/install.sh | sh
23
+
24
+ # On Windows.
25
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
26
+ ```
27
+
28
+ Then install `git-copilot-commit`:
29
+
30
+ ```bash
31
+ # Install into isolated environment.
19
32
  uv tool install git-copilot-commit
20
33
  ```
21
34
 
22
- Or with `pipx`:
35
+ Run the tool using:
23
36
 
24
37
  ```bash
25
- pipx install git-copilot-commit
38
+ git-copilot-commit --help
26
39
  ```
27
40
 
28
- Or run directly with [`uv`]:
41
+ Alternatively, you can always install and run the latest version of tool directly in one command by
42
+ using:
29
43
 
30
44
  ```bash
45
+ # Install latest version into temporary environment and run
31
46
  uvx git-copilot-commit --help
32
47
  ```
33
48
 
34
49
  [`uv`]: https://github.com/astral-sh/uv
35
50
 
51
+ ### Install with `pipx`
52
+
53
+ If you prefer to use `pipx`:
54
+
55
+ ```bash
56
+ pipx install git-copilot-commit
57
+ ```
58
+
36
59
  ## Prerequisites
37
60
 
38
61
  - Active GitHub Copilot subscription
@@ -41,17 +64,23 @@ uvx git-copilot-commit --help
41
64
 
42
65
  1. Authenticate with GitHub Copilot:
43
66
 
44
- ```bash
45
- git-copilot-commit authenticate
46
- ```
67
+ ```bash
68
+ git-copilot-commit authenticate
69
+ ```
47
70
 
48
71
  2. Make changes in your repository.
49
72
 
50
73
  3. Generate and commit:
51
74
 
52
- ```bash
53
- git-copilot-commit commit
54
- ```
75
+ ```bash
76
+ git-copilot-commit commit
77
+ ```
78
+
79
+ 4. Or, if you want to stage all files before committing use:
80
+
81
+ ```bash
82
+ git-copilot-commit commit --all
83
+ ```
55
84
 
56
85
  ## Usage
57
86
 
@@ -88,7 +117,7 @@ Options:
88
117
  $ uvx git-copilot-commit models --help
89
118
  Usage: git-copilot-commit models [OPTIONS]
90
119
 
91
- List models available for chat in a Rich table.
120
+ List models available for chat in a table.
92
121
 
93
122
  Options:
94
123
  --help Show this message and exit.
@@ -140,7 +169,7 @@ git-copilot-commit commit --model claude-3.5-sonnet
140
169
 
141
170
  Follows [Conventional Commits](https://www.conventionalcommits.org/):
142
171
 
143
- ```
172
+ ```plaintext
144
173
  <type>[optional scope]: <description>
145
174
  ```
146
175
 
@@ -156,31 +185,24 @@ Follows [Conventional Commits](https://www.conventionalcommits.org/):
156
185
  - `chore`: Maintenance
157
186
  - `revert`: Revert changes
158
187
 
159
- **Examples:**
160
-
161
- - `feat(auth): add JWT authentication`
162
- - `fix(db): retry connection on failure`
163
- - `docs(readme): update install steps`
164
- - `refactor(utils): simplify date parsing`
165
-
166
188
  ## Git Configuration
167
189
 
168
190
  Add a git alias by adding the following to your `~/.gitconfig`:
169
191
 
170
192
  ```ini
171
193
  [alias]
172
- ai-commit = "!f() { git-copilot-commit commit $@; }; f"
194
+ ai-commit = "!f() { uvx git-copilot-commit commit $@; }; f"
173
195
  ```
174
196
 
175
197
  Now you can run:
176
198
 
177
199
  ```bash
178
200
  git ai-commit
179
- git ai-commit --model claude-3.5-sonnet
180
201
  git ai-commit --all --verbose
202
+ git ai-commit --model claude-3.5-sonnet
181
203
  ```
182
204
 
183
- Show more context in diffs:
205
+ Additionally, show more context in diffs by running the following command:
184
206
 
185
207
  ```bash
186
208
  git config --global diff.context 3
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "git-copilot-commit"
3
+ dynamic = ["version"]
4
+ description = "Automatically generate and commit changes using copilot"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Dheepak Krishnamurthy", email = "1813121+kdheepak@users.noreply.github.com" },
8
+ ]
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "pycopilot>=0.1.6",
12
+ "rich>=14.0.0",
13
+ "typer>=0.16.0",
14
+ "platformdirs>=4.0.0",
15
+ ]
16
+
17
+ [project.scripts]
18
+ git-copilot-commit = "git_copilot_commit.cli:app"
19
+
20
+ [build-system]
21
+ requires = ["hatchling", "versioningit"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [tool.hatch.version]
25
+ source = "versioningit"
26
+
27
+ [tool.versioningit.next-version]
28
+ method = "smallest"
29
+
30
+ [tool.versioningit.format]
31
+ distance = "{next_version}.dev{distance}+{vcs}{rev}"
32
+ # Example formatted version: 1.2.4.dev42+ge174a1f
33
+
34
+ dirty = "{base_version}+d{build_date:%Y%m%d}"
35
+ # Example formatted version: 1.2.3+d20230922
36
+
37
+ distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}"
38
+ # Example formatted version: 1.2.4.dev42+ge174a1f.d20230922
@@ -21,7 +21,7 @@ app = typer.Typer(help=__doc__, add_completion=False)
21
21
 
22
22
  def version_callback(value: bool):
23
23
  if value:
24
- rich.print(f"git-copilot-version [bold green]{__version__}[/]")
24
+ rich.print(f"git-copilot-commit [bold green]{__version__}[/]")
25
25
  raise typer.Exit()
26
26
 
27
27
 
@@ -78,9 +78,13 @@ def generate_commit_message(
78
78
  ) -> str:
79
79
  """Generate a conventional commit message using Copilot API."""
80
80
 
81
- # Get recent commits for context
82
- recent_commits = repo.get_recent_commits(limit=5)
83
- recent_commits_text = "\n".join([f"- {msg}" for _, msg in recent_commits])
81
+ # Get recent commits for context (handle empty repositories)
82
+ try:
83
+ recent_commits = repo.get_recent_commits(limit=5)
84
+ recent_commits_text = "\n".join([f"- {msg}" for _, msg in recent_commits])
85
+ except GitError:
86
+ # No commits yet in this repository
87
+ recent_commits_text = "No previous commits (initial commit)"
84
88
 
85
89
  client = Copilot(
86
90
  system_prompt="""
@@ -172,6 +176,7 @@ Return the commit message as the output without any additional text, explanation
172
176
  )
173
177
 
174
178
  prompt = f"""Recent commits:
179
+
175
180
  {recent_commits_text}
176
181
 
177
182
  `git status`:
@@ -260,10 +265,14 @@ def commit(
260
265
  raise typer.Exit()
261
266
 
262
267
  # Generate or use provided commit message
263
- with console.status("[cyan]Generating commit message...[/cyan]"):
268
+ with console.status(
269
+ "[cyan]Generating commit message based on [bold]`git diff --staged`[/bold] ...[/cyan]"
270
+ ):
264
271
  commit_message = generate_commit_message(repo, status, model)
265
272
 
266
- console.print("[cyan]Generated commit message...[/cyan]")
273
+ console.print(
274
+ "[cyan]Generated commit message based on [bold]`git diff --staged`[/bold] ...[/cyan]"
275
+ )
267
276
 
268
277
  # Display commit message
269
278
  console.print(Panel(commit_message, title="Commit Message", border_style="green"))
@@ -315,7 +324,7 @@ def authenticate():
315
324
 
316
325
  @app.command()
317
326
  def models():
318
- """List models available for chat in a Rich table."""
327
+ """List models available for chat in a table."""
319
328
  models = Copilot().models
320
329
 
321
330
  console = Console()
@@ -0,0 +1,3 @@
1
+ import importlib.metadata
2
+
3
+ __version__ = importlib.metadata.version(__package__)
@@ -57,7 +57,6 @@ wheels = [
57
57
 
58
58
  [[package]]
59
59
  name = "git-copilot-commit"
60
- version = "0.1.9"
61
60
  source = { editable = "." }
62
61
  dependencies = [
63
62
  { name = "platformdirs" },
@@ -1,108 +0,0 @@
1
- [project]
2
- name = "git-copilot-commit"
3
- version = "0.1.9"
4
- description = "Automatically generate and commit changes using copilot"
5
- readme = "README.md"
6
- authors = [
7
- { name = "Dheepak Krishnamurthy", email = "1813121+kdheepak@users.noreply.github.com" },
8
- ]
9
- requires-python = ">=3.12"
10
- dependencies = [
11
- "pycopilot>=0.1.6",
12
- "rich>=14.0.0",
13
- "typer>=0.16.0",
14
- "platformdirs>=4.0.0",
15
- ]
16
-
17
- [project.scripts]
18
- git-copilot-commit = "git_copilot_commit.cli:app"
19
-
20
- [build-system]
21
- requires = ["hatchling"]
22
- build-backend = "hatchling.build"
23
-
24
- [tool.semantic_release]
25
- assets = []
26
- build_command_env = []
27
- commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
28
- commit_parser = "conventional"
29
- logging_use_named_masks = false
30
- major_on_zero = true
31
- allow_zero_version = false
32
- repo_dir = "."
33
- no_git_verify = false
34
- tag_format = "v{version}"
35
- version_toml = ["pyproject.toml:project.version"]
36
-
37
- [tool.semantic_release.branches.main]
38
- match = "(main|master)"
39
- prerelease_token = "rc"
40
- prerelease = false
41
-
42
- [tool.semantic_release.changelog]
43
- changelog_file = ""
44
- exclude_commit_patterns = []
45
- mode = "update"
46
- insertion_flag = "<!-- version list -->"
47
- template_dir = "templates"
48
-
49
- [tool.semantic_release.changelog.default_templates]
50
- changelog_file = "CHANGELOG.md"
51
- output_format = "md"
52
- mask_initial_release = true
53
-
54
- [tool.semantic_release.changelog.environment]
55
- block_start_string = "{%"
56
- block_end_string = "%}"
57
- variable_start_string = "{{"
58
- variable_end_string = "}}"
59
- comment_start_string = "{#"
60
- comment_end_string = "#}"
61
- trim_blocks = false
62
- lstrip_blocks = false
63
- newline_sequence = "\n"
64
- keep_trailing_newline = false
65
- extensions = []
66
- autoescape = false
67
-
68
- [tool.semantic_release.commit_author]
69
- env = "GIT_COMMIT_AUTHOR"
70
- default = "semantic-release <semantic-release>"
71
-
72
- [tool.semantic_release.commit_parser_options]
73
- minor_tags = ["feat"]
74
- patch_tags = ["fix", "perf"]
75
- other_allowed_tags = [
76
- "build",
77
- "chore",
78
- "ci",
79
- "docs",
80
- "style",
81
- "refactor",
82
- "test",
83
- ]
84
- allowed_tags = [
85
- "feat",
86
- "fix",
87
- "perf",
88
- "build",
89
- "chore",
90
- "ci",
91
- "docs",
92
- "style",
93
- "refactor",
94
- "test",
95
- ]
96
- default_bump_level = 0
97
- parse_squash_commits = true
98
- ignore_merge_commits = true
99
-
100
- [tool.semantic_release.remote]
101
- name = "origin"
102
- type = "github"
103
- ignore_token_for_push = false
104
- insecure = false
105
-
106
- [tool.semantic_release.publish]
107
- dist_glob_patterns = ["dist/*"]
108
- upload_to_vcs_release = true
@@ -1,40 +0,0 @@
1
- import subprocess
2
- import shlex
3
- from importlib import metadata
4
- import os
5
-
6
-
7
- DIR = os.path.dirname(os.path.realpath(__file__))
8
-
9
- VERSION = metadata.version(__package__ or "git-copilot-commit")
10
-
11
-
12
- def cmd(cmd, kind="") -> str:
13
- """
14
- Get git subprocess output
15
- """
16
- output = "unknown"
17
- try:
18
- output = (
19
- subprocess.check_output(shlex.split(cmd), cwd=DIR, stderr=subprocess.STDOUT)
20
- .decode()
21
- .strip()
22
- )
23
- except Exception as _:
24
- ...
25
- return f"{kind}{output}"
26
-
27
-
28
- def last_commit_id() -> str:
29
- return cmd("git describe --always --dirty --abbrev=7")
30
-
31
-
32
- def branch() -> str:
33
- return cmd("git rev-parse --abbrev-ref HEAD")
34
-
35
-
36
- def get_git_version() -> str:
37
- return f"{last_commit_id()}-{branch()}"
38
-
39
-
40
- __version__ = f"v{VERSION}-{get_git_version()}"