gitfluff 0.7.1__tar.gz → 0.9.0__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.1
2
2
  Name: gitfluff
3
- Version: 0.7.1
3
+ Version: 0.9.0
4
4
  Summary: Commit message linter and formatter
5
5
  Author-email: Na'aman Hirschfeld <nhirschfeld@gmail.com>
6
6
  License: MIT
@@ -27,7 +27,7 @@ Requires-Dist: certifi>=2024.7.4
27
27
 
28
28
  Commit message linter with presets, custom formats, and cleanup automation. Fully compliant with [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/). Skips linting while Git is creating a merge commit.
29
29
 
30
- This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`.
30
+ This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`. The binary's SHA-256 checksum is verified against the release's published checksums manifest before extraction.
31
31
 
32
32
  ## Quick Start
33
33
 
@@ -83,6 +83,8 @@ gitfluff hook install commit-msg
83
83
  gitfluff hook install commit-msg --write
84
84
  ```
85
85
 
86
+ Hook installation respects `core.hooksPath` (including relative paths) and works correctly in linked git worktrees.
87
+
86
88
  ### pre-commit Framework
87
89
 
88
90
  **Add to `.pre-commit-config.yaml`:**
@@ -94,7 +96,7 @@ default_install_hook_types:
94
96
 
95
97
  repos:
96
98
  - repo: https://github.com/Goldziher/gitfluff
97
- rev: v0.7.1
99
+ rev: v0.9.0
98
100
  hooks:
99
101
  - id: gitfluff-lint
100
102
  stages: [commit-msg]
@@ -134,14 +136,17 @@ preset = "conventional-body" # optional preset override
134
136
  write = true
135
137
 
136
138
  [rules]
139
+ no_emojis = true
140
+ ai_cleanup = true # set to false to disable AI attribution cleanup
141
+ title_suffix = "\\(JIRA-[0-9]+\\)"
137
142
  exit_nonzero_on_rewrite = true
138
143
  ```
139
144
 
140
- Any setting can be left out; omit the file entirely to keep defaults.
145
+ Any setting can be left out; omit the file entirely to keep defaults. Unknown config keys now trigger an error rather than being silently ignored.
141
146
 
142
147
  ## Advanced usage
143
148
 
144
- - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`).
149
+ - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`, `--no-emojis`, `--ascii-only`, `--title-prefix`, `--title-suffix`, `--no-ai-cleanup`).
145
150
  - Set `GITFLUFF_BINARY` to point at a custom build when testing unpublished versions.
146
151
  - Clear the cache (`rm ~/.cache/gitfluff/gitfluff*`) to force a fresh download.
147
152
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Commit message linter with presets, custom formats, and cleanup automation. Fully compliant with [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/). Skips linting while Git is creating a merge commit.
4
4
 
5
- This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`.
5
+ This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`. The binary's SHA-256 checksum is verified against the release's published checksums manifest before extraction.
6
6
 
7
7
  ## Quick Start
8
8
 
@@ -58,6 +58,8 @@ gitfluff hook install commit-msg
58
58
  gitfluff hook install commit-msg --write
59
59
  ```
60
60
 
61
+ Hook installation respects `core.hooksPath` (including relative paths) and works correctly in linked git worktrees.
62
+
61
63
  ### pre-commit Framework
62
64
 
63
65
  **Add to `.pre-commit-config.yaml`:**
@@ -69,7 +71,7 @@ default_install_hook_types:
69
71
 
70
72
  repos:
71
73
  - repo: https://github.com/Goldziher/gitfluff
72
- rev: v0.7.1
74
+ rev: v0.9.0
73
75
  hooks:
74
76
  - id: gitfluff-lint
75
77
  stages: [commit-msg]
@@ -109,14 +111,17 @@ preset = "conventional-body" # optional preset override
109
111
  write = true
110
112
 
111
113
  [rules]
114
+ no_emojis = true
115
+ ai_cleanup = true # set to false to disable AI attribution cleanup
116
+ title_suffix = "\\(JIRA-[0-9]+\\)"
112
117
  exit_nonzero_on_rewrite = true
113
118
  ```
114
119
 
115
- Any setting can be left out; omit the file entirely to keep defaults.
120
+ Any setting can be left out; omit the file entirely to keep defaults. Unknown config keys now trigger an error rather than being silently ignored.
116
121
 
117
122
  ## Advanced usage
118
123
 
119
- - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`).
124
+ - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`, `--no-emojis`, `--ascii-only`, `--title-prefix`, `--title-suffix`, `--no-ai-cleanup`).
120
125
  - Set `GITFLUFF_BINARY` to point at a custom build when testing unpublished versions.
121
126
  - Clear the cache (`rm ~/.cache/gitfluff/gitfluff*`) to force a fresh download.
122
127
 
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.7.1"
2
+ __version__ = "0.9.0"
@@ -2,20 +2,21 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import hashlib
5
6
  import os
6
7
  import platform
8
+ import ssl
7
9
  import subprocess
8
10
  import sys
9
- import tempfile
10
11
  import tarfile
12
+ import tempfile
11
13
  import zipfile
12
- import ssl
13
-
14
- import certifi
15
- from pathlib import Path
14
+ from pathlib import Path, PurePosixPath
16
15
  from urllib.error import URLError
17
16
  from urllib.request import Request, urlopen
18
17
 
18
+ import certifi
19
+
19
20
 
20
21
  def _platform_triple() -> str:
21
22
  system = platform.system().lower()
@@ -47,15 +48,18 @@ def _python_version_to_tag(version: str) -> str:
47
48
  return version
48
49
 
49
50
 
50
- def _asset(version: str) -> tuple[str, str]:
51
+ def _asset(version: str) -> tuple[str, str, str]:
52
+ """Return the (url, ext, name) of the release archive for this platform.
53
+
54
+ `name` is returned rather than recomputed by the caller: it is the key the checksum manifest
55
+ is looked up by, and a name derived separately from the URL could drift out of step with it.
56
+ """
51
57
  tag = _python_version_to_tag(version)
52
58
  triple = _platform_triple()
53
59
  ext = "zip" if "windows" in triple else "tar.gz"
54
- url = (
55
- f"https://github.com/Goldziher/gitfluff/releases/download/"
56
- f"v{tag}/gitfluff-{triple}.{ext}"
57
- )
58
- return url, ext
60
+ name = f"gitfluff-{triple}.{ext}"
61
+ url = f"https://github.com/Goldziher/gitfluff/releases/download/v{tag}/{name}"
62
+ return url, ext, name
59
63
 
60
64
 
61
65
  def _download(url: str, destination: Path) -> None:
@@ -81,15 +85,68 @@ def _extract(archive: Path, ext: str, destination: Path) -> None:
81
85
  else:
82
86
  with tarfile.open(archive, "r:gz") as tar:
83
87
  for member in tar.getmembers():
84
- if member.name.endswith("gitfluff") or member.name.endswith(
85
- "gitfluff.exe"
86
- ):
88
+ if member.name.endswith("gitfluff") or member.name.endswith("gitfluff.exe"):
87
89
  with tar.extractfile(member) as src, destination.open("wb") as dst:
88
90
  dst.write(src.read())
89
91
  return
90
92
  raise RuntimeError("Binary not found in downloaded archive")
91
93
 
92
94
 
95
+ def _download_text(url: str) -> str:
96
+ request = Request(url, headers={"User-Agent": "gitfluff-python-wrapper"})
97
+ context = ssl.create_default_context(cafile=certifi.where())
98
+ try:
99
+ with urlopen(request, timeout=30, context=context) as response:
100
+ if response.status != 200:
101
+ raise RuntimeError(f"HTTP {response.status}: {response.reason}")
102
+ return response.read().decode("utf-8")
103
+ except URLError as exc:
104
+ raise RuntimeError(f"Failed to download: {exc}") from exc
105
+
106
+
107
+ def _sha256_file(path: Path) -> str:
108
+ sha256_hash = hashlib.sha256()
109
+ with path.open("rb") as f:
110
+ for byte_block in iter(lambda: f.read(4096), b""):
111
+ sha256_hash.update(byte_block)
112
+ return sha256_hash.hexdigest()
113
+
114
+
115
+ def _verify_checksum(archive_path: Path, archive_name: str, version: str) -> None:
116
+ # The manifest is named after the release TAG, not the PyPI version string -- for a release
117
+ # candidate those differ (0.8.0rc1 vs 0.8.0-rc.1), and naming it after the version would
118
+ # request a file that does not exist.
119
+ tag = _python_version_to_tag(version)
120
+ checksum_url = f"https://github.com/Goldziher/gitfluff/releases/download/v{tag}/gitfluff_{tag}_checksums.txt"
121
+
122
+ print("Downloading checksums manifest...", file=sys.stderr)
123
+ checksum_text = _download_text(checksum_url)
124
+
125
+ # sha256sum format is "<hash> <name>". Match the name field exactly rather than with a
126
+ # substring test, so a manifest entry such as "<name>.sig" can never satisfy the lookup.
127
+ entry = next(
128
+ (
129
+ fields
130
+ for fields in (line.strip().split() for line in checksum_text.splitlines())
131
+ if len(fields) >= 2 and PurePosixPath(fields[-1]).name == archive_name
132
+ ),
133
+ None,
134
+ )
135
+
136
+ if entry is None:
137
+ raise RuntimeError(f"Checksum not found for {archive_name} in manifest")
138
+
139
+ expected_hash = entry[0]
140
+
141
+ print("Verifying archive checksum...", file=sys.stderr)
142
+ actual_hash = _sha256_file(archive_path)
143
+
144
+ if actual_hash != expected_hash:
145
+ raise RuntimeError(f"Checksum mismatch for {archive_name}\nExpected: {expected_hash}\nActual: {actual_hash}")
146
+
147
+ print("Checksum verified successfully.", file=sys.stderr)
148
+
149
+
93
150
  def _cache_path(version: str) -> Path:
94
151
  """
95
152
  Return a versioned cache path so upgrades download matching binaries.
@@ -103,7 +160,6 @@ def _cache_path(version: str) -> Path:
103
160
  def ensure_binary() -> str:
104
161
  from . import __version__
105
162
 
106
- # Allow override via environment for power users/tests
107
163
  override = os.getenv("GITFLUFF_BINARY")
108
164
  if override:
109
165
  return override
@@ -112,12 +168,13 @@ def ensure_binary() -> str:
112
168
  if binary_path.exists() and os.access(binary_path, os.X_OK):
113
169
  return str(binary_path)
114
170
 
115
- url, ext = _asset(__version__)
171
+ url, ext, archive_name = _asset(__version__)
116
172
  print(f"Downloading gitfluff binary v{__version__}...", file=sys.stderr)
117
173
 
118
174
  with tempfile.TemporaryDirectory() as tmpdir:
119
- archive_path = Path(tmpdir) / "gitfluff.tar.gz"
175
+ archive_path = Path(tmpdir) / f"gitfluff.{ext}"
120
176
  _download(url, archive_path)
177
+ _verify_checksum(archive_path, archive_name, __version__)
121
178
  _extract(archive_path, ext, binary_path)
122
179
 
123
180
  if platform.system().lower() != "windows":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitfluff
3
- Version: 0.7.1
3
+ Version: 0.9.0
4
4
  Summary: Commit message linter and formatter
5
5
  Author-email: Na'aman Hirschfeld <nhirschfeld@gmail.com>
6
6
  License: MIT
@@ -27,7 +27,7 @@ Requires-Dist: certifi>=2024.7.4
27
27
 
28
28
  Commit message linter with presets, custom formats, and cleanup automation. Fully compliant with [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/). Skips linting while Git is creating a merge commit.
29
29
 
30
- This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`.
30
+ This Python package distributes prebuilt `gitfluff` binaries. On first use, the correct release binary for your platform is downloaded and cached under `~/.cache/gitfluff`. The binary's SHA-256 checksum is verified against the release's published checksums manifest before extraction.
31
31
 
32
32
  ## Quick Start
33
33
 
@@ -83,6 +83,8 @@ gitfluff hook install commit-msg
83
83
  gitfluff hook install commit-msg --write
84
84
  ```
85
85
 
86
+ Hook installation respects `core.hooksPath` (including relative paths) and works correctly in linked git worktrees.
87
+
86
88
  ### pre-commit Framework
87
89
 
88
90
  **Add to `.pre-commit-config.yaml`:**
@@ -94,7 +96,7 @@ default_install_hook_types:
94
96
 
95
97
  repos:
96
98
  - repo: https://github.com/Goldziher/gitfluff
97
- rev: v0.7.1
99
+ rev: v0.9.0
98
100
  hooks:
99
101
  - id: gitfluff-lint
100
102
  stages: [commit-msg]
@@ -134,14 +136,17 @@ preset = "conventional-body" # optional preset override
134
136
  write = true
135
137
 
136
138
  [rules]
139
+ no_emojis = true
140
+ ai_cleanup = true # set to false to disable AI attribution cleanup
141
+ title_suffix = "\\(JIRA-[0-9]+\\)"
137
142
  exit_nonzero_on_rewrite = true
138
143
  ```
139
144
 
140
- Any setting can be left out; omit the file entirely to keep defaults.
145
+ Any setting can be left out; omit the file entirely to keep defaults. Unknown config keys now trigger an error rather than being silently ignored.
141
146
 
142
147
  ## Advanced usage
143
148
 
144
- - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`).
149
+ - Override rules per-invocation using CLI flags (e.g. `--preset`, `--msg-pattern`, `--cleanup-pattern`, `--exclude`, `--cleanup`, `--single-line`, `--no-emojis`, `--ascii-only`, `--title-prefix`, `--title-suffix`, `--no-ai-cleanup`).
145
150
  - Set `GITFLUFF_BINARY` to point at a custom build when testing unpublished versions.
146
151
  - Clear the cache (`rm ~/.cache/gitfluff/gitfluff*`) to force a fresh download.
147
152
 
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "gitfluff"
7
+ version = "0.9.0"
8
+ description = "Commit message linter and formatter"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Na'aman Hirschfeld", email = "nhirschfeld@gmail.com" }]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.8",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Build Tools",
23
+ "Environment :: Console",
24
+ ]
25
+ keywords = ["git", "commit", "lint", "conventional", "format"]
26
+ requires-python = ">=3.8"
27
+ dependencies = ["certifi>=2024.7.4"]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/Goldziher/gitfluff"
31
+ Repository = "https://github.com/Goldziher/gitfluff.git"
32
+ Issues = "https://github.com/Goldziher/gitfluff/issues"
33
+
34
+ [project.scripts]
35
+ gitfluff = "gitfluff.cli:main"
36
+
37
+ [tool.setuptools]
38
+ packages = ["gitfluff"]
@@ -1,42 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "gitfluff"
7
- version = "0.7.1"
8
- description = "Commit message linter and formatter"
9
- readme = "README.md"
10
- license = {text = "MIT"}
11
- authors = [
12
- {name = "Na'aman Hirschfeld", email = "nhirschfeld@gmail.com"}
13
- ]
14
- classifiers = [
15
- "Development Status :: 3 - Alpha",
16
- "Intended Audience :: Developers",
17
- "License :: OSI Approved :: MIT License",
18
- "Programming Language :: Python :: 3",
19
- "Programming Language :: Python :: 3.8",
20
- "Programming Language :: Python :: 3.9",
21
- "Programming Language :: Python :: 3.10",
22
- "Programming Language :: Python :: 3.11",
23
- "Programming Language :: Python :: 3.12",
24
- "Topic :: Software Development :: Build Tools",
25
- "Environment :: Console"
26
- ]
27
- keywords = ["git", "commit", "lint", "conventional", "format"]
28
- requires-python = ">=3.8"
29
- dependencies = [
30
- "certifi>=2024.7.4"
31
- ]
32
-
33
- [project.urls]
34
- Homepage = "https://github.com/Goldziher/gitfluff"
35
- Repository = "https://github.com/Goldziher/gitfluff.git"
36
- Issues = "https://github.com/Goldziher/gitfluff/issues"
37
-
38
- [project.scripts]
39
- gitfluff = "gitfluff.cli:main"
40
-
41
- [tool.setuptools]
42
- packages = ["gitfluff"]
File without changes
File without changes
File without changes