wexample-helpers-git 0.1.0__tar.gz → 0.2.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.
Files changed (15) hide show
  1. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/PKG-INFO +7 -4
  2. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/README.md +5 -2
  3. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/pyproject.toml +2 -2
  4. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/helpers/git.py +2 -7
  5. wexample_helpers_git-0.2.0/src/wexample_helpers_git/helpers/repo.py +43 -0
  6. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/__init__.py +0 -0
  7. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/__pycache__/__init__.py +0 -0
  8. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/const/__init__.py +0 -0
  9. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/const/common.py +0 -0
  10. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/helpers/__init__.py +0 -0
  11. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/helpers/__pycache__/__init__.py +0 -0
  12. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/helpers/git_retryable_callback_manager.py +0 -0
  13. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/src/wexample_helpers_git/py.typed +0 -0
  14. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/tests/helpers/__init__.py +0 -0
  15. {wexample_helpers_git-0.1.0 → wexample_helpers_git-0.2.0}/tests/helpers/test_helper_git.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wexample-helpers-git
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Some python basic helpers for git.
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>=0.7.0
15
+ Requires-Dist: wexample-helpers>=2.0.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: 0.1.0
23
+ Version: 0.2.0
24
24
 
25
25
  Some python basic helpers for git.
26
26
 
@@ -33,6 +33,7 @@ Some python basic helpers for git.
33
33
  - [License](#license)
34
34
  - [Suite Integration](#suite-integration)
35
35
  - [Suite Signature](#suite-signature)
36
+ - [Introduction](#introduction)
36
37
  - [Roadmap](#roadmap)
37
38
  - [Status Compatibility](#status-compatibility)
38
39
  - [Useful Links](#useful-links)
@@ -102,7 +103,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
102
103
  - attrs: >=23.1.0
103
104
  - cattrs: >=23.1.0
104
105
  - gitpython:
105
- - wexample-helpers: >=0.7.0
106
+ - wexample-helpers: >=2.0.0
106
107
 
107
108
  ## Versioning & Compatibility Policy
108
109
 
@@ -138,6 +139,8 @@ This packages suite embodies this spirit. Trusted by professionals and enthusias
138
139
 
139
140
  Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
140
141
 
142
+ A Python toolkit providing helper utilities for Git operations.
143
+
141
144
  ## Known Limitations & Roadmap
142
145
 
143
146
  Current limitations and planned features are tracked in the GitHub issues.
@@ -1,6 +1,6 @@
1
1
  # helpers_git
2
2
 
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
 
5
5
  Some python basic helpers for git.
6
6
 
@@ -13,6 +13,7 @@ Some python basic helpers for git.
13
13
  - [License](#license)
14
14
  - [Suite Integration](#suite-integration)
15
15
  - [Suite Signature](#suite-signature)
16
+ - [Introduction](#introduction)
16
17
  - [Roadmap](#roadmap)
17
18
  - [Status Compatibility](#status-compatibility)
18
19
  - [Useful Links](#useful-links)
@@ -82,7 +83,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
82
83
  - attrs: >=23.1.0
83
84
  - cattrs: >=23.1.0
84
85
  - gitpython:
85
- - wexample-helpers: >=0.7.0
86
+ - wexample-helpers: >=2.0.0
86
87
 
87
88
  ## Versioning & Compatibility Policy
88
89
 
@@ -118,6 +119,8 @@ This packages suite embodies this spirit. Trusted by professionals and enthusias
118
119
 
119
120
  Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
120
121
 
122
+ A Python toolkit providing helper utilities for Git operations.
123
+
121
124
  ## Known Limitations & Roadmap
122
125
 
123
126
  Current limitations and planned features are tracked in the GitHub issues.
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-helpers-git"
9
- version = "0.1.0"
9
+ version = "0.2.0"
10
10
  description = "Some python basic helpers for git."
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>=0.7.0",
24
+ "wexample-helpers>=2.0.0",
25
25
  ]
26
26
 
27
27
  [project.readme]
@@ -29,15 +29,10 @@ def git_commit_all_with_message(
29
29
  ) -> None:
30
30
  """Stage all changes (including new files) and commit with the provided message."""
31
31
  from wexample_helpers.helpers.file import file_resolve_path
32
- from wexample_helpers.helpers.shell import shell_run
33
32
 
34
33
  resolved = file_resolve_path(cwd)
35
- shell_run(["git", "add", "-A"], inherit_stdio=inherit_stdio, cwd=resolved)
36
- shell_run(
37
- ["git", "commit", "-m", message],
38
- inherit_stdio=inherit_stdio,
39
- cwd=resolved,
40
- )
34
+ git_run(["add", "-A"], inherit_stdio=inherit_stdio, cwd=resolved)
35
+ git_run(["commit", "-m", message], inherit_stdio=inherit_stdio, cwd=resolved)
41
36
 
42
37
 
43
38
  def git_create_or_switch_branch(
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from wexample_helpers.const.types import PathOrString
6
+
7
+ STATE_FILE = Path(".last_git_state")
8
+
9
+
10
+ def repo_get_state(cwd: PathOrString | None = None) -> str:
11
+ """Return a unique hash representing the current git state (HEAD + changes)."""
12
+ from wexample_helpers_git.helpers.git import git_run
13
+
14
+ head_result = git_run(["rev-parse", "HEAD"], cwd=cwd)
15
+ head_hash = head_result.stdout.strip() if head_result.stdout else ""
16
+
17
+ diff_result = git_run(["diff"], cwd=cwd)
18
+ diff_hash = diff_result.stdout if diff_result.stdout else ""
19
+
20
+ return f"{head_hash}-{hash(diff_hash)}"
21
+
22
+
23
+ def repo_has_changed(
24
+ cwd: PathOrString | None = None,
25
+ state_file: Path | None = None,
26
+ ) -> bool:
27
+ """Check if code has changed since last run."""
28
+ current_state = repo_get_state(cwd=cwd)
29
+ file_to_use = state_file if state_file is not None else STATE_FILE
30
+ previous_state = file_to_use.read_text().strip() if file_to_use.exists() else None
31
+ if current_state != previous_state:
32
+ file_to_use.write_text(current_state)
33
+ return True
34
+ return False
35
+
36
+
37
+ def repo_has_changed_since(
38
+ previous_state: str,
39
+ cwd: PathOrString | None = None,
40
+ ) -> bool:
41
+ """Return True if the repo state has changed compared to a provided hash."""
42
+ current_state = repo_get_state(cwd=cwd)
43
+ return current_state != previous_state