wexample-helpers-git 7.2.0__tar.gz → 7.3.1__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 (22) hide show
  1. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/PKG-INFO +3 -3
  2. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/README.md +1 -1
  3. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/pyproject.toml +2 -2
  4. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/helper/git.py +43 -1
  5. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/__init__.py +0 -0
  6. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/const/__init__.py +0 -0
  7. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/const/common.py +0 -0
  8. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/helper/__init__.py +0 -0
  9. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/helper/git_retryable_callback_manager.py +0 -0
  10. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/helper/gitignore.py +0 -0
  11. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/helper/repo.py +0 -0
  12. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/src/wexample_helpers_git/py.typed +0 -0
  13. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/.gitkeep +0 -0
  14. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/helper/__init__.py +0 -0
  15. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/helper/test_helper_git.py +0 -0
  16. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/helper/test_repo.py +0 -0
  17. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/__init__.py +0 -0
  18. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/helper/__init__.py +0 -0
  19. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/helper/test_git.py +0 -0
  20. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/helper/test_git_retryable_callback_manager.py +0 -0
  21. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/helper/test_gitignore.py +0 -0
  22. {wexample_helpers_git-7.2.0 → wexample_helpers_git-7.3.1}/tests/unit/helper/test_repo.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wexample-helpers-git
3
- Version: 7.2.0
3
+ Version: 7.3.1
4
4
  Summary: Python helpers for common Git automation: branch switching, staged commits, push/pull with retries, tag management, and change detection
5
5
  Author-Email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -12,7 +12,7 @@ Requires-Python: >=3.10
12
12
  Requires-Dist: attrs>=23.1.0
13
13
  Requires-Dist: cattrs>=23.1.0
14
14
  Requires-Dist: gitpython
15
- Requires-Dist: wexample-helpers>=20.7.0
15
+ Requires-Dist: wexample-helpers>=20.8.0
16
16
  Provides-Extra: dev
17
17
  Requires-Dist: pytest; extra == "dev"
18
18
  Requires-Dist: pytest-cov; extra == "dev"
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  # helpers_git
22
22
 
23
- Version: 7.2.0
23
+ Version: 7.3.1
24
24
 
25
25
  Python helpers for common Git automation: branch switching, staged commits, push/pull with retries, tag management, and change detection
26
26
 
@@ -1,6 +1,6 @@
1
1
  # helpers_git
2
2
 
3
- Version: 7.2.0
3
+ Version: 7.3.1
4
4
 
5
5
  Python helpers for common Git automation: branch switching, staged commits, push/pull with retries, tag management, and change detection
6
6
 
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-helpers-git"
9
- version = "7.2.0"
9
+ version = "7.3.1"
10
10
  description = "Python helpers for common Git automation: branch switching, staged commits, push/pull with retries, tag management, and change detection"
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
@@ -21,7 +21,7 @@ dependencies = [
21
21
  "attrs>=23.1.0",
22
22
  "cattrs>=23.1.0",
23
23
  "gitpython",
24
- "wexample-helpers>=20.7.0",
24
+ "wexample-helpers>=20.8.0",
25
25
  ]
26
26
 
27
27
  [project.readme]
@@ -45,6 +45,38 @@ def git_commit_all_with_message(
45
45
  )
46
46
 
47
47
 
48
+ def git_content_changed_files_since_tag(
49
+ tag: str,
50
+ pathspec: str = ".",
51
+ *,
52
+ cwd: FileStringOrPath,
53
+ ignore_whitespace: bool = False,
54
+ ) -> list[str]:
55
+ """The files in pathspec whose content changed since the given tag.
56
+
57
+ A file whose mode alone changed counts no line in `--numstat`, nor does one
58
+ whose only change is whitespace when ignore_whitespace is set; a binary
59
+ file counts as changed.
60
+ """
61
+ from wexample_helpers.helper.file import file_resolve_path
62
+
63
+ command = ["git", "diff", "--numstat"]
64
+ if ignore_whitespace:
65
+ command += ["-w", "--ignore-blank-lines"]
66
+ out = shell_run(
67
+ [*command, tag, "--", pathspec],
68
+ inherit_stdio=False,
69
+ cwd=file_resolve_path(cwd),
70
+ ).stdout
71
+
72
+ changed = []
73
+ for line in out.splitlines():
74
+ added, deleted, path = line.split("\t", 2)
75
+ if (added, deleted) != ("0", "0"):
76
+ changed.append(path)
77
+ return changed
78
+
79
+
48
80
  def git_create_or_switch_branch(
49
81
  branch: str, *, cwd: FileStringOrPath, inherit_stdio: bool = True
50
82
  ) -> None:
@@ -203,14 +235,24 @@ def git_get_upstream(*, cwd: FileStringOrPath, inherit_stdio: bool = False) -> s
203
235
 
204
236
 
205
237
  def git_has_changes_since_tag(
206
- tag: str, pathspec: str = ".", *, cwd: FileStringOrPath
238
+ tag: str,
239
+ pathspec: str = ".",
240
+ *,
241
+ cwd: FileStringOrPath,
242
+ content_only: bool = False,
207
243
  ) -> bool:
208
244
  """Return True if there are changes in pathspec since the given tag.
209
245
 
210
246
  Runs: git diff --quiet <tag> -- <pathspec> || echo CHANGED
247
+
248
+ content_only leaves out the files whose mode alone changed: what a bump is
249
+ measured on, a chmod changes nothing of the code.
211
250
  """
212
251
  from wexample_helpers.helper.file import file_resolve_path
213
252
 
253
+ if content_only:
254
+ return bool(git_content_changed_files_since_tag(tag, pathspec, cwd=cwd))
255
+
214
256
  out = shell_run(
215
257
  [
216
258
  "bash",