git-commit-message 0.9.0__py3-none-any.whl → 0.9.2__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.
@@ -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,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
 
@@ -0,0 +1,14 @@
1
+ git_commit_message/__init__.py,sha256=bmUVTlV1SYJAnoSaIKcpDCPkJ5JW2BANfFGvKt_A22w,190
2
+ git_commit_message/__main__.py,sha256=n5lvkLiCZ1Q4dwhEwonWntcKTeTaJL9qOJzdiLf0Gfk,99
3
+ git_commit_message/_cli.py,sha256=QWVENNmjrwiakpkXXy5Czbndt_IgcaQHhvuX5KMZ1V8,16801
4
+ git_commit_message/_config.py,sha256=-b0tDC7YvGVLWqz_ootOTvCAqDm_DK5ZjIX2BBOls6E,2089
5
+ git_commit_message/_gemini.py,sha256=QBKWnFCgc62KqC8agPhfO6eIizNj3V0oPTj6rqbTKiY,3487
6
+ git_commit_message/_git.py,sha256=7Hc4fl2Qp8UA9Xhk-yrNhKtEmVE8jOq7t_qCVQq8nbw,8146
7
+ git_commit_message/_gpt.py,sha256=baXHnhAXkeljjvSQqgQcxHaenOj5jvN7VmwapSjWGsE,3181
8
+ git_commit_message/_llamacpp.py,sha256=s5FeqexObi7qrOBYz1SLPxJi2xjBNH2-mOcMuKk0DkE,4294
9
+ git_commit_message/_llm.py,sha256=DK85Yo9Md5uQe99IHQELTslUUQEt6nqPst2PeHkIwys,21341
10
+ git_commit_message/_ollama.py,sha256=pj8rKE1-jETp91OCcVP7yui_1upWmZWeJpsYEc2H928,3024
11
+ git_commit_message-0.9.2.dist-info/WHEEL,sha256=bEhYrD-rjlF0iRRHiAnfJ0mEjMsRwm29hhDD7yRgWCY,80
12
+ git_commit_message-0.9.2.dist-info/entry_points.txt,sha256=T-3pK5LadeEm_vdS_3BZUv0VQXdgI0cwkfe5PnFPLD8,64
13
+ git_commit_message-0.9.2.dist-info/METADATA,sha256=p_SECWbfTLPQs9NoQlJ6vsdpOLgZEXyfejkB4nvXgEI,10613
14
+ git_commit_message-0.9.2.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: uv 0.11.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  git-commit-message = git_commit_message:main
3
+
@@ -1,15 +0,0 @@
1
- git_commit_message/__init__.py,sha256=bmUVTlV1SYJAnoSaIKcpDCPkJ5JW2BANfFGvKt_A22w,190
2
- git_commit_message/__main__.py,sha256=n5lvkLiCZ1Q4dwhEwonWntcKTeTaJL9qOJzdiLf0Gfk,99
3
- git_commit_message/_cli.py,sha256=0fIKoPeXZzAz6n6qOwHK2K2-inausMp3EHR3Feh9wP4,15349
4
- git_commit_message/_config.py,sha256=-b0tDC7YvGVLWqz_ootOTvCAqDm_DK5ZjIX2BBOls6E,2089
5
- git_commit_message/_gemini.py,sha256=QBKWnFCgc62KqC8agPhfO6eIizNj3V0oPTj6rqbTKiY,3487
6
- git_commit_message/_git.py,sha256=CCpPYUiKeFIyPCxCM1rSPZA0DRrEreNJ5oazJZBrLbI,6612
7
- git_commit_message/_gpt.py,sha256=baXHnhAXkeljjvSQqgQcxHaenOj5jvN7VmwapSjWGsE,3181
8
- git_commit_message/_llamacpp.py,sha256=s5FeqexObi7qrOBYz1SLPxJi2xjBNH2-mOcMuKk0DkE,4294
9
- git_commit_message/_llm.py,sha256=kimyKUZq8-BnQ6IyuKwyL0dh38rT_1zjuNfahGkmVy0,20683
10
- git_commit_message/_ollama.py,sha256=pj8rKE1-jETp91OCcVP7yui_1upWmZWeJpsYEc2H928,3024
11
- git_commit_message-0.9.0.dist-info/METADATA,sha256=kARTFHKefUFFRzGM8yfWBuTvhEGMWj6zeCrQ2mmi2Qc,10477
12
- git_commit_message-0.9.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
13
- git_commit_message-0.9.0.dist-info/entry_points.txt,sha256=e2cRvoyZnmP7yVItmFKwZofYG86WWKhm8KbzZSo2mf0,63
14
- git_commit_message-0.9.0.dist-info/top_level.txt,sha256=qeP45y7y44R4KrPEihvMdwdM8tXYDY_3nCvCD3I9EcI,19
15
- git_commit_message-0.9.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- git_commit_message