git-commit-message 0.9.0__tar.gz → 0.9.2__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 (21) hide show
  1. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/PKG-INFO +37 -36
  2. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/README.md +1 -1
  3. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/pyproject.toml +9 -12
  4. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_cli.py +47 -0
  5. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_git.py +74 -0
  6. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_llm.py +35 -7
  7. git_commit_message-0.9.0/setup.cfg +0 -4
  8. git_commit_message-0.9.0/src/git_commit_message.egg-info/PKG-INFO +0 -328
  9. git_commit_message-0.9.0/src/git_commit_message.egg-info/SOURCES.txt +0 -19
  10. git_commit_message-0.9.0/src/git_commit_message.egg-info/dependency_links.txt +0 -1
  11. git_commit_message-0.9.0/src/git_commit_message.egg-info/entry_points.txt +0 -2
  12. git_commit_message-0.9.0/src/git_commit_message.egg-info/requires.txt +0 -4
  13. git_commit_message-0.9.0/src/git_commit_message.egg-info/top_level.txt +0 -1
  14. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/UNLICENSE +0 -0
  15. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/__init__.py +0 -0
  16. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/__main__.py +0 -0
  17. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_config.py +0 -0
  18. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_gemini.py +0 -0
  19. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_gpt.py +0 -0
  20. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_llamacpp.py +0 -0
  21. {git_commit_message-0.9.0 → git_commit_message-0.9.2}/src/git_commit_message/_ollama.py +0 -0
@@ -1,37 +1,32 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: git-commit-message
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: Generate Git commit messages from staged changes using LLM
5
- Maintainer-email: Mina Her <minacle@live.com>
6
5
  License: This is free and unencumbered software released into the public domain.
7
-
8
- Anyone is free to copy, modify, publish, use, compile, sell, or
9
- distribute this software, either in source code form or as a compiled
10
- binary, for any purpose, commercial or non-commercial, and by any
11
- means.
12
-
13
- In jurisdictions that recognize copyright laws, the author or authors
14
- of this software dedicate any and all copyright interest in the
15
- software to the public domain. We make this dedication for the benefit
16
- of the public at large and to the detriment of our heirs and
17
- successors. We intend this dedication to be an overt act of
18
- relinquishment in perpetuity of all present and future rights to this
19
- software under copyright law.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- OTHER DEALINGS IN THE SOFTWARE.
28
-
29
- For more information, please refer to <https://unlicense.org/>
30
-
31
- Project-URL: Homepage, https://github.com/minacle/git-commit-message
32
- Project-URL: Repository, https://github.com/minacle/git-commit-message
33
- Project-URL: Issues, https://github.com/minacle/git-commit-message/issues
34
- Classifier: Development Status :: 3 - Alpha
6
+
7
+ Anyone is free to copy, modify, publish, use, compile, sell, or
8
+ distribute this software, either in source code form or as a compiled
9
+ binary, for any purpose, commercial or non-commercial, and by any
10
+ means.
11
+
12
+ In jurisdictions that recognize copyright laws, the author or authors
13
+ of this software dedicate any and all copyright interest in the
14
+ software to the public domain. We make this dedication for the benefit
15
+ of the public at large and to the detriment of our heirs and
16
+ successors. We intend this dedication to be an overt act of
17
+ relinquishment in perpetuity of all present and future rights to this
18
+ software under copyright law.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
+ OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+ For more information, please refer to <https://unlicense.org/>
29
+ Classifier: Development Status :: 4 - Beta
35
30
  Classifier: Environment :: Console
36
31
  Classifier: Intended Audience :: Developers
37
32
  Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
@@ -40,13 +35,19 @@ Classifier: Programming Language :: Python
40
35
  Classifier: Programming Language :: Python :: 3
41
36
  Classifier: Programming Language :: Python :: 3 :: Only
42
37
  Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: Programming Language :: Python :: 3.14
43
39
  Classifier: Topic :: Software Development :: Version Control :: Git
40
+ Requires-Dist: babel>=2.18.0
41
+ Requires-Dist: google-genai>=1.73.1
42
+ Requires-Dist: ollama>=0.6.1
43
+ Requires-Dist: openai>=2.32.0
44
+ Maintainer: Mina Her
45
+ Maintainer-email: Mina Her <minacle@live.com>
44
46
  Requires-Python: >=3.13
47
+ Project-URL: Homepage, https://github.com/minacle/git-commit-message
48
+ Project-URL: Repository, https://github.com/minacle/git-commit-message
49
+ Project-URL: Issues, https://github.com/minacle/git-commit-message/issues
45
50
  Description-Content-Type: text/markdown
46
- Requires-Dist: babel>=2.17.0
47
- Requires-Dist: google-genai>=1.56.0
48
- Requires-Dist: ollama>=0.4.0
49
- Requires-Dist: openai>=2.6.1
50
51
 
51
52
  # git-commit-message
52
53
 
@@ -293,7 +294,7 @@ git-commit-message --provider llamacpp --host http://192.168.1.100:8080
293
294
  - `--amend`: generate a message suitable for amending the previous commit (diff is from the amended commit's parent to the staged index; if nothing is staged, this effectively becomes the diff introduced by `HEAD`)
294
295
  - `--edit`: with `--commit`, open editor for final message
295
296
  - `--host URL`: host URL for providers like Ollama or llama.cpp (default: `http://localhost:11434` for Ollama, `http://localhost:8080` for llama.cpp)
296
- - `--co-author VALUE`: append `Co-authored-by:` trailer(s). Repeat to add multiple values. Accepted forms: `Name <email@example.com>` or `copilot` (alias, case-insensitive).
297
+ - `--co-author VALUE`: append `Co-authored-by:` trailer(s). Repeat to add multiple values. Accepted forms: `Name <email@example.com>` or an alias keyword (`claude-code`, `codex`, `copilot`, `copilot-cli`; case-insensitive).
297
298
 
298
299
  ## Environment variables
299
300
 
@@ -243,7 +243,7 @@ git-commit-message --provider llamacpp --host http://192.168.1.100:8080
243
243
  - `--amend`: generate a message suitable for amending the previous commit (diff is from the amended commit's parent to the staged index; if nothing is staged, this effectively becomes the diff introduced by `HEAD`)
244
244
  - `--edit`: with `--commit`, open editor for final message
245
245
  - `--host URL`: host URL for providers like Ollama or llama.cpp (default: `http://localhost:11434` for Ollama, `http://localhost:8080` for llama.cpp)
246
- - `--co-author VALUE`: append `Co-authored-by:` trailer(s). Repeat to add multiple values. Accepted forms: `Name <email@example.com>` or `copilot` (alias, case-insensitive).
246
+ - `--co-author VALUE`: append `Co-authored-by:` trailer(s). Repeat to add multiple values. Accepted forms: `Name <email@example.com>` or an alias keyword (`claude-code`, `codex`, `copilot`, `copilot-cli`; case-insensitive).
247
247
 
248
248
  ## Environment variables
249
249
 
@@ -1,19 +1,19 @@
1
1
  [project]
2
2
  name = "git-commit-message"
3
- version = "0.9.0"
3
+ version = "0.9.2"
4
4
  description = "Generate Git commit messages from staged changes using LLM"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
8
- "babel>=2.17.0",
9
- "google-genai>=1.56.0",
10
- "ollama>=0.4.0",
11
- "openai>=2.6.1",
8
+ "babel>=2.18.0",
9
+ "google-genai>=1.73.1",
10
+ "ollama>=0.6.1",
11
+ "openai>=2.32.0",
12
12
  ]
13
13
  maintainers = [{ name = "Mina Her", email = "minacle@live.com" }]
14
14
  license = { file = "UNLICENSE" }
15
15
  classifiers = [
16
- "Development Status :: 3 - Alpha",
16
+ "Development Status :: 4 - Beta",
17
17
  "Environment :: Console",
18
18
  "Intended Audience :: Developers",
19
19
  "License :: OSI Approved :: The Unlicense (Unlicense)",
@@ -22,6 +22,7 @@ classifiers = [
22
22
  "Programming Language :: Python :: 3",
23
23
  "Programming Language :: Python :: 3 :: Only",
24
24
  "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
25
26
  "Topic :: Software Development :: Version Control :: Git",
26
27
  ]
27
28
 
@@ -29,12 +30,8 @@ classifiers = [
29
30
  git-commit-message = "git_commit_message:main"
30
31
 
31
32
  [build-system]
32
- requires = ["setuptools>=80", "wheel"]
33
- build-backend = "setuptools.build_meta"
34
-
35
- [tool.setuptools]
36
- package-dir = {"" = "src"}
37
- packages = ["git_commit_message"]
33
+ requires = ["uv_build>=0.11.3,<0.12.0"]
34
+ build-backend = "uv_build"
38
35
 
39
36
  [project.urls]
40
37
  Homepage = "https://github.com/minacle/git-commit-message"
@@ -17,6 +17,8 @@ from typing import Final
17
17
 
18
18
  from ._git import (
19
19
  commit_with_message,
20
+ get_current_branch,
21
+ get_git_log,
20
22
  get_repo_root,
21
23
  get_staged_diff,
22
24
  has_head_commit,
@@ -47,6 +49,9 @@ class CliArgs(Namespace):
47
49
  "max_length",
48
50
  "chunk_tokens",
49
51
  "diff_context",
52
+ "no_branch",
53
+ "no_log",
54
+ "log_count",
50
55
  "host",
51
56
  "co_authors",
52
57
  )
@@ -68,6 +73,9 @@ class CliArgs(Namespace):
68
73
  self.max_length: int | None = None
69
74
  self.chunk_tokens: int | None = None
70
75
  self.diff_context: int | None = None
76
+ self.no_branch: bool = False
77
+ self.no_log: bool = False
78
+ self.log_count: int = 10
71
79
  self.host: str | None = None
72
80
  self.co_authors: list[str] | None = None
73
81
 
@@ -76,7 +84,10 @@ _CO_AUTHOR_LINE_RE: Final[Pattern[str]] = re.compile(
76
84
  r"^\s*([^<>\s\n][^<>\n]*?)\s*<([^<>\s\n]+@[^<>\s\n]+)>\s*$"
77
85
  )
78
86
  _CO_AUTHOR_ALIASES: Final[dict[str, str]] = {
87
+ "claude-code": "Claude <noreply@anthropic.com>",
88
+ "codex": "Codex <noreply@openai.com>",
79
89
  "copilot": "Copilot <copilot@github.com>",
90
+ "copilot-cli": "Copilot <223556219+Copilot@users.noreply.github.com>",
80
91
  }
81
92
 
82
93
 
@@ -304,6 +315,31 @@ def _build_parser() -> ArgumentParser:
304
315
  ),
305
316
  )
306
317
 
318
+ parser.add_argument(
319
+ "--no-branch",
320
+ dest="no_branch",
321
+ action="store_true",
322
+ help="Do not include the current branch name in the LLM context.",
323
+ )
324
+
325
+ parser.add_argument(
326
+ "--no-log",
327
+ dest="no_log",
328
+ action="store_true",
329
+ help="Do not include recent Git log entries in the LLM context.",
330
+ )
331
+
332
+ parser.add_argument(
333
+ "--log-count",
334
+ dest="log_count",
335
+ type=int,
336
+ default=10,
337
+ help=(
338
+ "Number of recent Git log entries to include in the LLM context "
339
+ "(default: 10). Ignored when --no-log is set."
340
+ ),
341
+ )
342
+
307
343
  parser.add_argument(
308
344
  "--host",
309
345
  dest="host",
@@ -370,6 +406,10 @@ def _run(
370
406
  print("--diff-context must be greater than or equal to 0.", file=stderr)
371
407
  return 2
372
408
 
409
+ if not args.no_log and args.log_count < 1:
410
+ print("--log-count must be greater than or equal to 1.", file=stderr)
411
+ return 2
412
+
373
413
  provider_name: str = resolve_provider_name(args.provider)
374
414
  provider_arg_error = validate_provider_chunk_tokens(provider_name, chunk_tokens)
375
415
  if provider_arg_error is not None:
@@ -396,6 +436,9 @@ def _run(
396
436
 
397
437
  diff_text = get_staged_diff(repo_root, context_lines=diff_context)
398
438
 
439
+ branch: str | None = None if args.no_branch else get_current_branch(repo_root)
440
+ log: str | None = None if args.no_log else get_git_log(repo_root, count=args.log_count)
441
+
399
442
  hint: str | None = args.description if isinstance(args.description, str) else None
400
443
 
401
444
  normalized_co_authors: list[str] | None = None
@@ -420,6 +463,8 @@ def _run(
420
463
  args.provider,
421
464
  args.host,
422
465
  args.conventional,
466
+ branch=branch,
467
+ log=log,
423
468
  )
424
469
  message = result.message
425
470
  else:
@@ -434,6 +479,8 @@ def _run(
434
479
  args.provider,
435
480
  args.host,
436
481
  args.conventional,
482
+ branch=branch,
483
+ log=log,
437
484
  )
438
485
  except UnsupportedProviderError as exc:
439
486
  print(str(exc), file=stderr)
@@ -232,6 +232,80 @@ def get_staged_diff(
232
232
  return out.decode()
233
233
 
234
234
 
235
+ def get_current_branch(
236
+ cwd: Path,
237
+ /,
238
+ ) -> str | None:
239
+ """Return the current branch name, or ``None`` if HEAD is detached.
240
+
241
+ Parameters
242
+ ----------
243
+ cwd
244
+ Repository directory in which to run Git.
245
+
246
+ Returns
247
+ -------
248
+ str | None
249
+ Branch name, or ``None`` when HEAD is detached or the command fails.
250
+ """
251
+
252
+ completed = run(
253
+ ["git", "branch", "--show-current"],
254
+ cwd=str(cwd),
255
+ check=False,
256
+ capture_output=True,
257
+ )
258
+ if completed.returncode != 0:
259
+ return None
260
+ name = completed.stdout.decode().strip()
261
+ return name or None
262
+
263
+
264
+ def get_git_log(
265
+ cwd: Path,
266
+ /,
267
+ *,
268
+ count: int = 10,
269
+ ) -> str | None:
270
+ """Return recent Git log entries as formatted text.
271
+
272
+ Parameters
273
+ ----------
274
+ cwd
275
+ Repository directory in which to run Git.
276
+ count
277
+ Maximum number of commits to include.
278
+
279
+ Returns
280
+ -------
281
+ str | None
282
+ Formatted log text, or ``None`` if the repository has no commits
283
+ or if ``git log`` fails.
284
+ """
285
+
286
+ if count < 1:
287
+ raise ValueError(f"count must be >= 1, got {count}")
288
+
289
+ if not has_head_commit(cwd):
290
+ return None
291
+
292
+ try:
293
+ out: bytes = check_output(
294
+ [
295
+ "git",
296
+ "log",
297
+ f"-{count}",
298
+ "--format=%h %s%n%n%b%n---%n",
299
+ ],
300
+ cwd=str(cwd),
301
+ )
302
+ except CalledProcessError:
303
+ return None
304
+
305
+ text = out.decode().strip()
306
+ return text or None
307
+
308
+
235
309
  def commit_with_message(
236
310
  message: str,
237
311
  edit: bool,
@@ -298,12 +298,19 @@ def _build_combined_prompt(
298
298
  hint: str | None,
299
299
  content_label: str = "Changes (diff)",
300
300
  /,
301
+ *,
302
+ branch: str | None = None,
303
+ log: str | None = None,
301
304
  ) -> str:
302
- hint_content: str | None = (
303
- f"# Auxiliary context (user-provided)\n{hint}" if hint else None
304
- )
305
- content: str = f"# {content_label}\n{diff}"
306
- return "\n\n".join([part for part in (hint_content, content) if part is not None])
305
+ parts: list[str] = []
306
+ if hint:
307
+ parts.append(f"# Auxiliary context (user-provided)\n{hint}")
308
+ if branch:
309
+ parts.append(f"# Current branch\n{branch}")
310
+ if log:
311
+ parts.append(f"# Recent commits\n{log}")
312
+ parts.append(f"# {content_label}\n{diff}")
313
+ return "\n\n".join(parts)
307
314
 
308
315
 
309
316
  def _split_diff_into_hunks(
@@ -423,6 +430,9 @@ def _generate_commit_from_summaries(
423
430
  language: str,
424
431
  conventional: bool = False,
425
432
  /,
433
+ *,
434
+ branch: str | None = None,
435
+ log: str | None = None,
426
436
  ) -> LLMTextResult:
427
437
  instructions = _build_system_prompt(single_line, subject_max, language, conventional)
428
438
  sections: list[str] = []
@@ -430,6 +440,12 @@ def _generate_commit_from_summaries(
430
440
  if hint:
431
441
  sections.append(f"# Auxiliary context (user-provided)\n{hint}")
432
442
 
443
+ if branch:
444
+ sections.append(f"# Current branch\n{branch}")
445
+
446
+ if log:
447
+ sections.append(f"# Recent commits\n{log}")
448
+
433
449
  if summaries:
434
450
  numbered = [
435
451
  f"Summary {idx + 1}:\n{summary}" for idx, summary in enumerate(summaries)
@@ -490,6 +506,9 @@ def generate_commit_message(
490
506
  host: str | None = None,
491
507
  conventional: bool = False,
492
508
  /,
509
+ *,
510
+ branch: str | None = None,
511
+ log: str | None = None,
493
512
  ) -> str:
494
513
  chosen_provider = resolve_provider_name(provider)
495
514
  chosen_model = resolve_model_name(model, chosen_provider)
@@ -523,11 +542,13 @@ def generate_commit_message(
523
542
  subject_max,
524
543
  chosen_language,
525
544
  conventional,
545
+ branch=branch,
546
+ log=log,
526
547
  )
527
548
  text = (final.text or "").strip()
528
549
  else:
529
550
  instructions = _build_system_prompt(single_line, subject_max, chosen_language, conventional)
530
- user_text = _build_combined_prompt(diff, hint)
551
+ user_text = _build_combined_prompt(diff, hint, branch=branch, log=log)
531
552
  final = llm.generate_text(
532
553
  model=chosen_model,
533
554
  instructions=instructions,
@@ -553,6 +574,9 @@ def generate_commit_message_with_info(
553
574
  host: str | None = None,
554
575
  conventional: bool = False,
555
576
  /,
577
+ *,
578
+ branch: str | None = None,
579
+ log: str | None = None,
556
580
  ) -> CommitMessageResult:
557
581
  chosen_provider = resolve_provider_name(provider)
558
582
  chosen_model = resolve_model_name(model, chosen_provider)
@@ -588,12 +612,16 @@ def generate_commit_message_with_info(
588
612
  subject_max,
589
613
  chosen_language,
590
614
  conventional,
615
+ branch=branch,
616
+ log=log,
591
617
  )
592
618
 
593
619
  combined_prompt = _build_combined_prompt(
594
620
  "\n".join(summary_texts),
595
621
  hint,
596
622
  "Combined summaries (English)",
623
+ branch=branch,
624
+ log=log,
597
625
  )
598
626
 
599
627
  prompt_tokens, completion_tokens, total_tokens = _sum_usage(
@@ -605,7 +633,7 @@ def generate_commit_message_with_info(
605
633
 
606
634
  else:
607
635
  instructions = _build_system_prompt(single_line, subject_max, chosen_language, conventional)
608
- combined_prompt = _build_combined_prompt(diff, hint)
636
+ combined_prompt = _build_combined_prompt(diff, hint, branch=branch, log=log)
609
637
 
610
638
  final_result = llm.generate_text(
611
639
  model=chosen_model,
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,328 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: git-commit-message
3
- Version: 0.9.0
4
- Summary: Generate Git commit messages from staged changes using LLM
5
- Maintainer-email: Mina Her <minacle@live.com>
6
- License: This is free and unencumbered software released into the public domain.
7
-
8
- Anyone is free to copy, modify, publish, use, compile, sell, or
9
- distribute this software, either in source code form or as a compiled
10
- binary, for any purpose, commercial or non-commercial, and by any
11
- means.
12
-
13
- In jurisdictions that recognize copyright laws, the author or authors
14
- of this software dedicate any and all copyright interest in the
15
- software to the public domain. We make this dedication for the benefit
16
- of the public at large and to the detriment of our heirs and
17
- successors. We intend this dedication to be an overt act of
18
- relinquishment in perpetuity of all present and future rights to this
19
- software under copyright law.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- OTHER DEALINGS IN THE SOFTWARE.
28
-
29
- For more information, please refer to <https://unlicense.org/>
30
-
31
- Project-URL: Homepage, https://github.com/minacle/git-commit-message
32
- Project-URL: Repository, https://github.com/minacle/git-commit-message
33
- Project-URL: Issues, https://github.com/minacle/git-commit-message/issues
34
- Classifier: Development Status :: 3 - Alpha
35
- Classifier: Environment :: Console
36
- Classifier: Intended Audience :: Developers
37
- Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
38
- Classifier: Operating System :: OS Independent
39
- Classifier: Programming Language :: Python
40
- Classifier: Programming Language :: Python :: 3
41
- Classifier: Programming Language :: Python :: 3 :: Only
42
- Classifier: Programming Language :: Python :: 3.13
43
- Classifier: Topic :: Software Development :: Version Control :: Git
44
- Requires-Python: >=3.13
45
- Description-Content-Type: text/markdown
46
- Requires-Dist: babel>=2.17.0
47
- Requires-Dist: google-genai>=1.56.0
48
- Requires-Dist: ollama>=0.4.0
49
- Requires-Dist: openai>=2.6.1
50
-
51
- # git-commit-message
52
-
53
- Generate a commit message from your staged changes using OpenAI, Google Gemini, Ollama, or llama.cpp.
54
-
55
- [![asciicast](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN.svg)](https://asciinema.org/a/jk0phFqNnc5vaCiIZEYBwZOyN)
56
-
57
- ## Requirements
58
-
59
- - Python 3.13+
60
- - A Git repo with staged changes (`git add ...`) (or use `--amend` even if nothing is staged)
61
-
62
- ## Install
63
-
64
- Install the latest released version from PyPI:
65
-
66
- ```sh
67
- # User environment (recommended)
68
- python -m pip install --user git-commit-message
69
-
70
- # Or system/virtualenv as appropriate
71
- python -m pip install git-commit-message
72
-
73
- # Or with pipx for isolated CLI installs
74
- pipx install git-commit-message
75
-
76
- # Upgrade to the newest version
77
- python -m pip install --upgrade git-commit-message
78
- ```
79
-
80
- Quick check:
81
-
82
- ```sh
83
- git-commit-message --help
84
- ```
85
-
86
- ## Setup
87
-
88
- ### OpenAI
89
-
90
- ```sh
91
- export OPENAI_API_KEY="sk-..."
92
- ```
93
-
94
- ### Google Gemini
95
-
96
- ```sh
97
- export GOOGLE_API_KEY="..."
98
- ```
99
-
100
- ### Ollama (local models)
101
-
102
- 1. Install Ollama: https://ollama.ai
103
- 2. Start the server:
104
-
105
- ```sh
106
- ollama serve
107
- ```
108
-
109
- 3. Pull a model:
110
-
111
- ```sh
112
- ollama pull mistral
113
- ```
114
-
115
- Optional: set defaults:
116
-
117
- ```sh
118
- export GIT_COMMIT_MESSAGE_PROVIDER=ollama
119
- export OLLAMA_MODEL=mistral
120
- ```
121
-
122
- ### llama.cpp (local models)
123
-
124
- 1. Build and run llama.cpp server with your model:
125
-
126
- ```sh
127
- llama-server -hf ggml-org/gpt-oss-20b-GGUF --host 0.0.0.0 --port 8080
128
- ```
129
-
130
- 2. The server runs on `http://localhost:8080` by default.
131
-
132
- Optional: set defaults:
133
-
134
- ```sh
135
- export GIT_COMMIT_MESSAGE_PROVIDER=llamacpp
136
- export LLAMACPP_HOST=http://localhost:8080
137
- ```
138
-
139
- Note (fish):
140
-
141
- ```fish
142
- set -x OPENAI_API_KEY "sk-..."
143
- ```
144
-
145
- ## Install (editable)
146
-
147
- ```sh
148
- python -m pip install -e .
149
- ```
150
-
151
- ## Usage
152
-
153
- Generate and print a commit message:
154
-
155
- ```sh
156
- git add -A
157
- git-commit-message "optional extra context about the change"
158
- ```
159
-
160
- Generate a single-line subject only (when no trailers are appended):
161
-
162
- ```sh
163
- git-commit-message --one-line "optional context"
164
-
165
- # with trailers, output is subject plus trailer lines
166
- git-commit-message --one-line --co-author 'John Doe <john.doe@example.com>'
167
- ```
168
-
169
- Use Conventional Commits constraints for the subject/footer only (body format is preserved):
170
-
171
- ```sh
172
- git-commit-message --conventional
173
-
174
- # can be combined with one-line mode
175
- git-commit-message --conventional --one-line
176
-
177
- # co-author trailers are appended after any existing footers
178
- git-commit-message --conventional --co-author copilot
179
- ```
180
-
181
- Select provider:
182
-
183
- ```sh
184
- # OpenAI (default)
185
- git-commit-message --provider openai
186
-
187
- # Google Gemini (via google-genai)
188
- git-commit-message --provider google
189
-
190
- # Ollama
191
- git-commit-message --provider ollama
192
-
193
- # llama.cpp
194
- git-commit-message --provider llamacpp
195
- ```
196
-
197
- Commit immediately (optionally open editor):
198
-
199
- ```sh
200
- git-commit-message --commit "refactor parser for speed"
201
- git-commit-message --commit --edit "refactor parser for speed"
202
-
203
- # add co-author trailers
204
- git-commit-message --commit --co-author 'John Doe <john.doe@example.com>'
205
- git-commit-message --commit --co-author 'John Doe <john.doe@example.com>' --co-author 'Jane Doe <jane.doe@example.com>'
206
- git-commit-message --commit --co-author copilot
207
- ```
208
-
209
- Amend the previous commit:
210
-
211
- ```sh
212
- # print only (useful for pasting into a GUI editor)
213
- git-commit-message --amend "optional context"
214
-
215
- # amend immediately
216
- git-commit-message --commit --amend "optional context"
217
-
218
- # amend immediately, but open editor for final tweaks
219
- git-commit-message --commit --amend --edit "optional context"
220
- ```
221
-
222
- Limit subject length:
223
-
224
- ```sh
225
- git-commit-message --one-line --max-length 50
226
- ```
227
-
228
- Chunk/summarise long diffs by token budget:
229
-
230
- ```sh
231
- # force a single summary pass over the whole diff (default)
232
- git-commit-message --chunk-tokens 0
233
-
234
- # chunk the diff into ~4000-token pieces before summarising
235
- git-commit-message --chunk-tokens 4000
236
-
237
- # note: for provider 'ollama', values >= 1 are not supported
238
- # use 0 (single summary pass) or -1 (legacy one-shot)
239
- git-commit-message --provider ollama --chunk-tokens 0
240
-
241
- # disable summarisation and use the legacy one-shot prompt
242
- git-commit-message --chunk-tokens -1
243
- ```
244
-
245
- Adjust unified diff context lines:
246
-
247
- ```sh
248
- # use 5 context lines around each change hunk
249
- git-commit-message --diff-context 5
250
-
251
- # include only changed lines (no surrounding context)
252
- git-commit-message --diff-context 0
253
- ```
254
-
255
- Select output language/locale (IETF language tag):
256
-
257
- ```sh
258
- git-commit-message --language en-US
259
- git-commit-message --language ko-KR
260
- git-commit-message --language ja-JP
261
- ```
262
-
263
- Print debug info:
264
-
265
- ```sh
266
- git-commit-message --debug
267
- ```
268
-
269
- Configure Ollama host (if running on a different machine):
270
-
271
- ```sh
272
- git-commit-message --provider ollama --host http://192.168.1.100:11434
273
- ```
274
-
275
- Configure llama.cpp host:
276
-
277
- ```sh
278
- git-commit-message --provider llamacpp --host http://192.168.1.100:8080
279
- ```
280
-
281
- ## Options
282
-
283
- - `--provider {openai,google,ollama,llamacpp}`: provider to use (default: `openai`)
284
- - `--model MODEL`: model override (provider-specific; ignored for llama.cpp)
285
- - `--language TAG`: output language/locale (default: `en-GB`)
286
- - `--conventional`: apply Conventional Commits constraints to the subject and footer behavior. The body format is unchanged and still includes the translated `Rationale:` line. Breaking changes are expressed with `!` in the subject line, and `BREAKING CHANGE` footer lines are not generated.
287
- - `--one-line`: output subject only when no trailers are appended; with `--co-author`, output is a single-line subject plus `Co-authored-by:` trailer lines
288
- - `--max-length N`: max subject length (default: 72)
289
- - `--chunk-tokens N`: token budget per diff chunk (`0` = single summary pass, `-1` disables summarisation). For `ollama`, values `>= 1` are not supported.
290
- - `--diff-context N`: context lines in unified diff (`N >= 0`). If omitted, uses `GIT_COMMIT_MESSAGE_DIFF_CONTEXT` when set; otherwise uses Git default (usually `3`).
291
- - `--debug`: print request/response details
292
- - `--commit`: run `git commit -m <message>`
293
- - `--amend`: generate a message suitable for amending the previous commit (diff is from the amended commit's parent to the staged index; if nothing is staged, this effectively becomes the diff introduced by `HEAD`)
294
- - `--edit`: with `--commit`, open editor for final message
295
- - `--host URL`: host URL for providers like Ollama or llama.cpp (default: `http://localhost:11434` for Ollama, `http://localhost:8080` for llama.cpp)
296
- - `--co-author VALUE`: append `Co-authored-by:` trailer(s). Repeat to add multiple values. Accepted forms: `Name <email@example.com>` or `copilot` (alias, case-insensitive).
297
-
298
- ## Environment variables
299
-
300
- Required:
301
-
302
- - `OPENAI_API_KEY`: when provider is `openai`
303
- - `GOOGLE_API_KEY`: when provider is `google`
304
-
305
- Optional:
306
-
307
- - `GIT_COMMIT_MESSAGE_PROVIDER`: default provider (`openai` by default). `--provider` overrides this.
308
- - `GIT_COMMIT_MESSAGE_MODEL`: model override for any provider. `--model` overrides this.
309
- - `OPENAI_MODEL`: OpenAI-only model override (used if `--model`/`GIT_COMMIT_MESSAGE_MODEL` are not set)
310
- - `OLLAMA_MODEL`: Ollama-only model override (used if `--model`/`GIT_COMMIT_MESSAGE_MODEL` are not set)
311
- - `OLLAMA_HOST`: Ollama server URL (default: `http://localhost:11434`)
312
- - `LLAMACPP_HOST`: llama.cpp server URL (default: `http://localhost:8080`)
313
- - `GIT_COMMIT_MESSAGE_LANGUAGE`: default language/locale (default: `en-GB`)
314
- - `GIT_COMMIT_MESSAGE_CHUNK_TOKENS`: default chunk token budget (default: `0`; for `ollama`, values `>= 1` are not supported)
315
- - `GIT_COMMIT_MESSAGE_DIFF_CONTEXT`: default unified diff context lines (`0` or greater). If unset, Git default is used (usually `3`).
316
-
317
- Default models (if not overridden):
318
-
319
- - OpenAI: `gpt-5-mini`
320
- - Google: `gemini-2.5-flash`
321
- - Ollama: `gpt-oss:20b`
322
- - llama.cpp: uses pre-loaded model (model parameter is ignored)
323
-
324
- ## AI-generated code notice
325
-
326
- Parts of this project were created with assistance from AI tools (e.g. large language models).
327
- All AI-assisted contributions were reviewed and adapted by maintainers before inclusion.
328
- If you need provenance for specific changes, please refer to the Git history and commit messages.
@@ -1,19 +0,0 @@
1
- README.md
2
- UNLICENSE
3
- pyproject.toml
4
- src/git_commit_message/__init__.py
5
- src/git_commit_message/__main__.py
6
- src/git_commit_message/_cli.py
7
- src/git_commit_message/_config.py
8
- src/git_commit_message/_gemini.py
9
- src/git_commit_message/_git.py
10
- src/git_commit_message/_gpt.py
11
- src/git_commit_message/_llamacpp.py
12
- src/git_commit_message/_llm.py
13
- src/git_commit_message/_ollama.py
14
- src/git_commit_message.egg-info/PKG-INFO
15
- src/git_commit_message.egg-info/SOURCES.txt
16
- src/git_commit_message.egg-info/dependency_links.txt
17
- src/git_commit_message.egg-info/entry_points.txt
18
- src/git_commit_message.egg-info/requires.txt
19
- src/git_commit_message.egg-info/top_level.txt
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- git-commit-message = git_commit_message:main
@@ -1,4 +0,0 @@
1
- babel>=2.17.0
2
- google-genai>=1.56.0
3
- ollama>=0.4.0
4
- openai>=2.6.1
@@ -1 +0,0 @@
1
- git_commit_message