wexample-helpers-git 6.1.0__tar.gz → 6.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-6.1.0 → wexample_helpers_git-6.2.0}/PKG-INFO +2 -2
  2. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/README.md +1 -1
  3. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/pyproject.toml +1 -1
  4. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/helpers/git.py +30 -0
  5. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/__init__.py +0 -0
  6. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/__pycache__/__init__.py +0 -0
  7. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/const/__init__.py +0 -0
  8. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/const/common.py +0 -0
  9. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/helpers/__init__.py +0 -0
  10. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/helpers/__pycache__/__init__.py +0 -0
  11. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/helpers/git_retryable_callback_manager.py +0 -0
  12. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/helpers/repo.py +0 -0
  13. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/src/wexample_helpers_git/py.typed +0 -0
  14. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.2.0}/tests/helpers/__init__.py +0 -0
  15. {wexample_helpers_git-6.1.0 → wexample_helpers_git-6.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: 6.1.0
3
+ Version: 6.2.0
4
4
  Summary: Some python basic helpers for git.
5
5
  Author-Email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  # helpers_git
22
22
 
23
- Version: 6.1.0
23
+ Version: 6.2.0
24
24
 
25
25
  Some python basic helpers for git.
26
26
 
@@ -1,6 +1,6 @@
1
1
  # helpers_git
2
2
 
3
- Version: 6.1.0
3
+ Version: 6.2.0
4
4
 
5
5
  Some python basic helpers for git.
6
6
 
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-helpers-git"
9
- version = "6.1.0"
9
+ version = "6.2.0"
10
10
  description = "Some python basic helpers for git."
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
@@ -442,3 +442,33 @@ def git_tag_exists(
442
442
  return len(out) > 0
443
443
  except Exception:
444
444
  return False
445
+
446
+
447
+ def git_tag_lightweight(
448
+ tag: str, *, cwd: FileStringOrPath, force: bool = False, inherit_stdio: bool = True
449
+ ) -> None:
450
+ """Create (or force-update) a lightweight tag at HEAD."""
451
+ from wexample_helpers.helpers.file import file_resolve_path
452
+
453
+ cmd = ["tag"]
454
+ if force:
455
+ cmd.append("-f")
456
+ cmd.append(tag)
457
+ git_run(cmd, inherit_stdio=inherit_stdio, cwd=file_resolve_path(cwd))
458
+
459
+
460
+ def git_tag_points_to_head(tag: str, *, cwd: FileStringOrPath) -> bool:
461
+ """Return True if the given tag resolves to the same commit as HEAD."""
462
+ from wexample_helpers.helpers.file import file_resolve_path
463
+ from wexample_helpers.helpers.shell import shell_run
464
+
465
+ try:
466
+ tag_hash = shell_run(
467
+ ["git", "rev-parse", f"refs/tags/{tag}^{{}}"],
468
+ inherit_stdio=False,
469
+ cwd=file_resolve_path(cwd),
470
+ ).stdout.strip()
471
+ head_hash = git_get_current_commit_hash(cwd=cwd)
472
+ return bool(tag_hash) and tag_hash == head_hash
473
+ except Exception:
474
+ return False