gha-utils 4.16.2__tar.gz → 4.16.4__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.

Potentially problematic release.


This version of gha-utils might be problematic. Click here for more details.

Files changed (23) hide show
  1. {gha_utils-4.16.2 → gha_utils-4.16.4}/PKG-INFO +3 -3
  2. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/__init__.py +1 -1
  3. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/cli.py +2 -2
  4. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/mailmap.py +21 -3
  5. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/metadata.py +4 -12
  6. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/PKG-INFO +3 -3
  7. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/requires.txt +2 -2
  8. {gha_utils-4.16.2 → gha_utils-4.16.4}/pyproject.toml +4 -4
  9. {gha_utils-4.16.2 → gha_utils-4.16.4}/tests/test_mailmap.py +45 -2
  10. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/__main__.py +0 -0
  11. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/changelog.py +0 -0
  12. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/matrix.py +0 -0
  13. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/py.typed +0 -0
  14. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils/test_plan.py +0 -0
  15. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/SOURCES.txt +0 -0
  16. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/dependency_links.txt +0 -0
  17. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/entry_points.txt +0 -0
  18. {gha_utils-4.16.2 → gha_utils-4.16.4}/gha_utils.egg-info/top_level.txt +0 -0
  19. {gha_utils-4.16.2 → gha_utils-4.16.4}/readme.md +0 -0
  20. {gha_utils-4.16.2 → gha_utils-4.16.4}/setup.cfg +0 -0
  21. {gha_utils-4.16.2 → gha_utils-4.16.4}/tests/test_changelog.py +0 -0
  22. {gha_utils-4.16.2 → gha_utils-4.16.4}/tests/test_matrix.py +0 -0
  23. {gha_utils-4.16.2 → gha_utils-4.16.4}/tests/test_metadata.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gha-utils
3
- Version: 4.16.2
3
+ Version: 4.16.4
4
4
  Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
5
  Author-email: Kevin Deldycke <kevin@deldycke.com>
6
6
  Project-URL: Homepage, https://github.com/kdeldycke/workflows
@@ -46,8 +46,8 @@ Requires-Python: >=3.11
46
46
  Description-Content-Type: text/markdown
47
47
  Requires-Dist: boltons>=24.0.0
48
48
  Requires-Dist: bump-my-version<1.1.1,>=0.32.2
49
- Requires-Dist: click-extra~=4.15.0
50
- Requires-Dist: extra-platforms~=3.1.0
49
+ Requires-Dist: click-extra~=5.0.0
50
+ Requires-Dist: extra-platforms~=3.2.0
51
51
  Requires-Dist: packaging~=25.0
52
52
  Requires-Dist: PyDriller~=2.6
53
53
  Requires-Dist: pyproject-metadata~=0.9.0
@@ -17,4 +17,4 @@
17
17
 
18
18
  from __future__ import annotations
19
19
 
20
- __version__ = "4.16.2"
20
+ __version__ = "4.16.4"
@@ -38,7 +38,7 @@ from click_extra import (
38
38
  pass_context,
39
39
  )
40
40
  from click_extra.envvar import merge_envvar_ids
41
- from extra_platforms import ALL_IDS
41
+ from extra_platforms import ALL_IDS, is_github_ci
42
42
 
43
43
  from . import __version__
44
44
  from .changelog import Changelog
@@ -156,7 +156,7 @@ def metadata(ctx, format, overwrite, output_path):
156
156
  metadata = Metadata()
157
157
 
158
158
  # Output a warning in GitHub runners if metadata are not saved to $GITHUB_OUTPUT.
159
- if metadata.in_ci_env:
159
+ if is_github_ci():
160
160
  env_file = os.getenv("GITHUB_OUTPUT")
161
161
  if env_file and Path(env_file) != output_path:
162
162
  logging.warning(
@@ -25,7 +25,7 @@ from subprocess import run
25
25
  from boltons.iterutils import unique
26
26
 
27
27
 
28
- @dataclass(order=True, frozen=True)
28
+ @dataclass(order=True)
29
29
  class Record:
30
30
  """A mailmap identity mapping entry."""
31
31
 
@@ -35,6 +35,11 @@ class Record:
35
35
  aliases: set[str] = field(default_factory=set)
36
36
  pre_comment: str = ""
37
37
 
38
+ def __post_init__(self) -> None:
39
+ """Empty pre-comment are normalized to empty string, even if they are multi-lines."""
40
+ if self.pre_comment.strip() == "":
41
+ self.pre_comment = ""
42
+
38
43
  def __str__(self) -> str:
39
44
  """Render the record with pre-comments first, followed by the identity mapping.
40
45
 
@@ -58,7 +63,11 @@ class Mailmap:
58
63
  <https://git-scm.com/docs/gitmailmap>`_.
59
64
  """
60
65
 
61
- records: list[Record] = list()
66
+ records: list[Record]
67
+
68
+ def __init__(self) -> None:
69
+ """Initialize the mailmap with an empty list of records."""
70
+ self.records = []
62
71
 
63
72
  @staticmethod
64
73
  def split_identities(mapping: str) -> tuple[str, set[str]]:
@@ -161,6 +170,15 @@ class Mailmap:
161
170
 
162
171
  def render(self) -> str:
163
172
  """Render internal records in Mailmap format."""
164
- return "\n".join(
173
+ # Extract the pre-comment from the first record, if any, so we can keep it
174
+ # attached to the top of the file.
175
+ top_comment = self.records[0].pre_comment if self.records else ""
176
+ if top_comment:
177
+ top_comment += "\n"
178
+ # Reset the pre-comment of the first record, so it doesn't get duplicated
179
+ # in the output.
180
+ self.records[0].pre_comment = ""
181
+
182
+ return top_comment + "\n".join(
165
183
  map(str, sorted(self.records, key=lambda r: r.canonical.casefold()))
166
184
  )
@@ -173,6 +173,7 @@ from typing import Any, Final, Iterator, cast
173
173
  from bumpversion.config import get_configuration # type: ignore[import-untyped]
174
174
  from bumpversion.config.files import find_config_file # type: ignore[import-untyped]
175
175
  from bumpversion.show import resolve_name # type: ignore[import-untyped]
176
+ from extra_platforms import is_github_ci
176
177
  from packaging.specifiers import SpecifierSet
177
178
  from packaging.version import Version
178
179
  from pydriller import Commit, Git, Repository # type: ignore[import-untyped]
@@ -291,15 +292,6 @@ class Metadata:
291
292
  pyproject_path = Path() / "pyproject.toml"
292
293
  sphinx_conf_path = Path() / "docs" / "conf.py"
293
294
 
294
- @cached_property
295
- def in_ci_env(self) -> bool:
296
- """Returns ``True`` if the code is executed in a GitHub Actions runner.
297
-
298
- Other CI are available at:
299
- https://github.com/cucumber/ci-environment/blob/main/python/src/ci_environment/CiEnvironments.json
300
- """
301
- return bool("GITHUB_RUN_ID" in os.environ)
302
-
303
295
  @cached_property
304
296
  def github_context(self) -> dict[str, Any]:
305
297
  """Load GitHub context from the environment.
@@ -321,7 +313,7 @@ class Metadata:
321
313
  JSON/env hack above.
322
314
  """
323
315
  if "GITHUB_CONTEXT" not in os.environ:
324
- if self.in_ci_env:
316
+ if is_github_ci():
325
317
  message = (
326
318
  "Missing GitHub context in environment. "
327
319
  "Did you forget to set GITHUB_CONTEXT?"
@@ -401,7 +393,7 @@ class Metadata:
401
393
  "We need to look into the commit history. Inspect the initial state of the repository."
402
394
  )
403
395
 
404
- if not self.in_ci_env:
396
+ if not is_github_ci():
405
397
  raise RuntimeError(
406
398
  "Local repository manipulations only allowed in CI environment"
407
399
  )
@@ -476,7 +468,7 @@ class Metadata:
476
468
  .. todo::
477
469
  Add detection of all workflow trigger events.
478
470
  """
479
- if not self.in_ci_env:
471
+ if not is_github_ci():
480
472
  logging.warning(
481
473
  "Cannot guess event type because we're not in a CI environment."
482
474
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gha-utils
3
- Version: 4.16.2
3
+ Version: 4.16.4
4
4
  Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
5
  Author-email: Kevin Deldycke <kevin@deldycke.com>
6
6
  Project-URL: Homepage, https://github.com/kdeldycke/workflows
@@ -46,8 +46,8 @@ Requires-Python: >=3.11
46
46
  Description-Content-Type: text/markdown
47
47
  Requires-Dist: boltons>=24.0.0
48
48
  Requires-Dist: bump-my-version<1.1.1,>=0.32.2
49
- Requires-Dist: click-extra~=4.15.0
50
- Requires-Dist: extra-platforms~=3.1.0
49
+ Requires-Dist: click-extra~=5.0.0
50
+ Requires-Dist: extra-platforms~=3.2.0
51
51
  Requires-Dist: packaging~=25.0
52
52
  Requires-Dist: PyDriller~=2.6
53
53
  Requires-Dist: pyproject-metadata~=0.9.0
@@ -1,7 +1,7 @@
1
1
  boltons>=24.0.0
2
2
  bump-my-version<1.1.1,>=0.32.2
3
- click-extra~=4.15.0
4
- extra-platforms~=3.1.0
3
+ click-extra~=5.0.0
4
+ extra-platforms~=3.2.0
5
5
  packaging~=25.0
6
6
  PyDriller~=2.6
7
7
  pyproject-metadata~=0.9.0
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  # Docs: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
3
3
  name = "gha-utils"
4
- version = "4.16.2"
4
+ version = "4.16.4"
5
5
  # Python versions and their status: https://devguide.python.org/versions/
6
6
  requires-python = ">= 3.11"
7
7
  description = "⚙️ CLI helpers for GitHub Actions + reuseable workflows"
@@ -74,8 +74,8 @@ dependencies = [
74
74
  # v0.32.2 is the first fixing an issue preventing compilation with Nuitka.
75
75
  # v1.1.1 and later have some regressions: see https://github.com/callowayproject/bump-my-version/issues/331
76
76
  "bump-my-version >= 0.32.2, < 1.1.1",
77
- "click-extra ~= 4.15.0",
78
- "extra-platforms ~= 3.1.0",
77
+ "click-extra ~= 5.0.0",
78
+ "extra-platforms ~= 3.2.0",
79
79
  "packaging ~= 25.0",
80
80
  "PyDriller ~= 2.6",
81
81
  "pyproject-metadata ~= 0.9.0",
@@ -137,7 +137,7 @@ addopts = [
137
137
  xfail_strict = true
138
138
 
139
139
  [tool.bumpversion]
140
- current_version = "4.16.2"
140
+ current_version = "4.16.4"
141
141
  allow_dirty = true
142
142
  ignore_missing_files = true
143
143
 
@@ -19,7 +19,7 @@ from __future__ import annotations
19
19
  from textwrap import dedent
20
20
 
21
21
  from gha_utils.cli import remove_header
22
- from gha_utils.mailmap import Mailmap
22
+ from gha_utils.mailmap import Mailmap, Record
23
23
 
24
24
 
25
25
  def test_remove_header():
@@ -67,7 +67,50 @@ def test_mailmap():
67
67
  GitHub <noreply@github.com>
68
68
  GitHub <noreply@github.com> dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
69
69
  GitHub <noreply@github.com>
70
+ github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> GitHub Actions <actions@github.com>"""
71
+ )
70
72
 
71
73
 
72
- github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> GitHub Actions <actions@github.com>"""
74
+ def test_new_entry():
75
+ mailmap = Mailmap()
76
+
77
+ header = dedent(
78
+ """\
79
+ # Generated by gha-utils mailmap-sync v4.16.2 - https://github.com/kdeldycke/workflows
80
+ # Timestamp: 2025-05-13T13:14:51.128939
81
+ # Format is:
82
+ # Preferred Name <preferred e-mail> Other Name <other e-mail>
83
+ #
84
+ # Reference: https://git-scm.com/docs/git-blame#_mapping_authors"""
85
+ )
86
+
87
+ mailmap.parse(
88
+ dedent(
89
+ f"""\
90
+ {header}
91
+ dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
92
+
93
+
94
+ """
95
+ )
96
+ )
97
+
98
+ assert len(mailmap.records) == 1
99
+ assert (
100
+ mailmap.records[0].canonical
101
+ == "dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>"
102
+ )
103
+ assert mailmap.records[0].aliases == set()
104
+ assert mailmap.records[0].pre_comment == header
105
+
106
+ # Add new record manually
107
+ new_contributor = "AA BB <aa@bb.example.org>"
108
+ mailmap.records.append(Record(canonical=new_contributor))
109
+
110
+ assert mailmap.render() == (
111
+ header
112
+ + "\n"
113
+ + new_contributor
114
+ + "\n"
115
+ + "dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>"
73
116
  )
File without changes
File without changes