scitex-git 0.1.3__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.
- {scitex_git-0.1.3/src/scitex_git.egg-info → scitex_git-0.2.0}/PKG-INFO +64 -21
- {scitex_git-0.1.3 → scitex_git-0.2.0}/README.md +61 -19
- {scitex_git-0.1.3 → scitex_git-0.2.0}/pyproject.toml +3 -2
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/__init__.py +24 -1
- scitex_git-0.2.0/src/scitex_git/_gh_secrets.py +215 -0
- scitex_git-0.2.0/src/scitex_git/_skills/scitex-git/01_installation.md +46 -0
- scitex_git-0.2.0/src/scitex_git/_skills/scitex-git/02_quick-start.md +58 -0
- scitex_git-0.2.0/src/scitex_git/_skills/scitex-git/03_python-api.md +78 -0
- scitex_git-0.2.0/src/scitex_git/_skills/scitex-git/SKILL.md +30 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0/src/scitex_git.egg-info}/PKG-INFO +64 -21
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git.egg-info/SOURCES.txt +4 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git.egg-info/requires.txt +1 -0
- scitex_git-0.1.3/src/scitex_git/_skills/scitex-git/SKILL.md +0 -25
- {scitex_git-0.1.3 → scitex_git-0.2.0}/LICENSE +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/setup.cfg +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_branch.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_clone.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_commit.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_constants.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_init.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_remote.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_result.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_retry.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_types.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_utils.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_validation.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_vendor_sh.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git/_workflow.py +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git.egg-info/dependency_links.txt +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git.egg-info/entry_points.txt +0 -0
- {scitex_git-0.1.3 → scitex_git-0.2.0}/src/scitex_git.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scitex-git
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Git
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Git + GitHub Actions utilities (clone, branch, commit, retry, remote helpers, gh secrets/variables with SHA256 sidecar) — standalone module from the SciTeX ecosystem
|
|
5
5
|
Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
|
|
6
6
|
License-Expression: AGPL-3.0-only
|
|
7
7
|
Project-URL: Homepage, https://github.com/ywatanabe1989/scitex-git
|
|
@@ -25,6 +25,7 @@ Provides-Extra: dev
|
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
26
26
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
27
27
|
Requires-Dist: ruff; extra == "dev"
|
|
28
|
+
Requires-Dist: scitex-dev>=0.11.5; extra == "dev"
|
|
28
29
|
Provides-Extra: docs
|
|
29
30
|
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
30
31
|
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
|
|
@@ -37,16 +38,6 @@ Dynamic: license-file
|
|
|
37
38
|
|
|
38
39
|
# scitex-git
|
|
39
40
|
|
|
40
|
-
<!-- scitex-badges:start -->
|
|
41
|
-
[](https://pypi.org/project/scitex-git/)
|
|
42
|
-
[](https://pypi.org/project/scitex-git/)
|
|
43
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml)
|
|
44
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml)
|
|
45
|
-
[](https://codecov.io/gh/ywatanabe1989/scitex-git)
|
|
46
|
-
[](https://scitex-git.readthedocs.io/en/latest/)
|
|
47
|
-
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
48
|
-
<!-- scitex-badges:end -->
|
|
49
|
-
|
|
50
41
|
<p align="center">
|
|
51
42
|
<a href="https://scitex.ai">
|
|
52
43
|
<img src="docs/scitex-logo-blue-cropped.png" alt="SciTeX" width="400">
|
|
@@ -59,6 +50,18 @@ Dynamic: license-file
|
|
|
59
50
|
<a href="https://scitex-git.readthedocs.io/">Full Documentation</a> · <code>pip install scitex-git</code>
|
|
60
51
|
</p>
|
|
61
52
|
|
|
53
|
+
<!-- scitex-badges:start -->
|
|
54
|
+
<p align="center">
|
|
55
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/v/scitex-git.svg" alt="PyPI"></a>
|
|
56
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/pyversions/scitex-git.svg" alt="Python"></a>
|
|
57
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
|
|
58
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml/badge.svg" alt="Install Test"></a>
|
|
59
|
+
<a href="https://codecov.io/gh/ywatanabe1989/scitex-git"><img src="https://codecov.io/gh/ywatanabe1989/scitex-git/graph/badge.svg" alt="Coverage"></a>
|
|
60
|
+
<a href="https://scitex-git.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/scitex-git/badge/?version=latest" alt="Docs"></a>
|
|
61
|
+
<a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/license-AGPL_v3-blue.svg" alt="License: AGPL v3"></a>
|
|
62
|
+
</p>
|
|
63
|
+
<!-- scitex-badges:end -->
|
|
64
|
+
|
|
62
65
|
---
|
|
63
66
|
|
|
64
67
|
## Installation
|
|
@@ -67,19 +70,29 @@ Dynamic: license-file
|
|
|
67
70
|
pip install scitex-git
|
|
68
71
|
```
|
|
69
72
|
|
|
70
|
-
##
|
|
73
|
+
## Architecture
|
|
71
74
|
|
|
72
|
-
```python
|
|
73
|
-
import scitex_git as sxg
|
|
74
|
-
|
|
75
|
-
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
76
|
-
sxg.git_add_all("./bar")
|
|
77
|
-
sxg.git_commit("./bar", message="initial")
|
|
78
75
|
```
|
|
76
|
+
scitex_git/
|
|
77
|
+
├── _clone.py ← clone_repo, ls_remote, get_remote_url
|
|
78
|
+
├── _init.py ← git_init, init_git_repo, find_parent_git
|
|
79
|
+
├── _commit.py ← git_add_all, git_commit
|
|
80
|
+
├── _branch.py ← checkout_new_branch, branch_rename, setup_branches
|
|
81
|
+
├── _remote.py ← remote-URL helpers, head-hash queries
|
|
82
|
+
├── _retry.py ← @git_retry decorator (transient-error backoff)
|
|
83
|
+
├── _validation.py ← repo-state guards
|
|
84
|
+
├── _workflow.py ← high-level multi-step flows
|
|
85
|
+
├── _vendor_sh.py ← ~70-LOC subprocess wrapper (replaces scitex.sh)
|
|
86
|
+
└── _skills/ ← agent-facing skill pages
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Pure-stdlib core. `_vendor_sh.py` is intentionally tiny so the package
|
|
90
|
+
has no `scitex.*` runtime dependency. The umbrella `scitex.git` import
|
|
91
|
+
resolves through a `sys.modules` bridge.
|
|
79
92
|
|
|
80
93
|
## 1 Interfaces
|
|
81
94
|
|
|
82
|
-
<details>
|
|
95
|
+
<details open>
|
|
83
96
|
<summary><strong>Python API</strong></summary>
|
|
84
97
|
|
|
85
98
|
<br>
|
|
@@ -119,6 +132,34 @@ def maybe_flaky_operation(): ...
|
|
|
119
132
|
|
|
120
133
|
</details>
|
|
121
134
|
|
|
135
|
+
## Demo
|
|
136
|
+
|
|
137
|
+
```mermaid
|
|
138
|
+
flowchart LR
|
|
139
|
+
A["scitex_git.clone_repo<br/>(url, dest)"] --> B["@git_retry<br/>(transient errors)"]
|
|
140
|
+
B --> C["repo on disk"]
|
|
141
|
+
C --> D["git_add_all + git_commit"]
|
|
142
|
+
D --> E["checkout_new_branch<br/>+ branch_rename"]
|
|
143
|
+
E --> F["get_remote_url /<br/>get_head_hash"]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
>>> import scitex_git as sxg
|
|
148
|
+
>>> sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
149
|
+
>>> sxg.git_add_all("./bar")
|
|
150
|
+
>>> sxg.git_commit("./bar", message="initial")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Quick Start
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
import scitex_git as sxg
|
|
157
|
+
|
|
158
|
+
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
159
|
+
sxg.git_add_all("./bar")
|
|
160
|
+
sxg.git_commit("./bar", message="initial")
|
|
161
|
+
```
|
|
162
|
+
|
|
122
163
|
## Status
|
|
123
164
|
|
|
124
165
|
Standalone fork of `scitex.git`. `scitex.logging.getLogger` is replaced by stdlib
|
|
@@ -133,7 +174,9 @@ The umbrella package's `scitex.git` import path is preserved via a
|
|
|
133
174
|
|
|
134
175
|
## Part of SciTeX
|
|
135
176
|
|
|
136
|
-
`scitex-git` is part of [**SciTeX**](https://scitex.ai).
|
|
177
|
+
`scitex-git` is part of [**SciTeX**](https://scitex.ai). Install via
|
|
178
|
+
the umbrella with `pip install scitex[git]` to use as
|
|
179
|
+
`scitex.git` (Python) or `scitex git ...` (CLI).
|
|
137
180
|
|
|
138
181
|
>Four Freedoms for Research
|
|
139
182
|
>
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
# scitex-git
|
|
2
2
|
|
|
3
|
-
<!-- scitex-badges:start -->
|
|
4
|
-
[](https://pypi.org/project/scitex-git/)
|
|
5
|
-
[](https://pypi.org/project/scitex-git/)
|
|
6
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml)
|
|
7
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml)
|
|
8
|
-
[](https://codecov.io/gh/ywatanabe1989/scitex-git)
|
|
9
|
-
[](https://scitex-git.readthedocs.io/en/latest/)
|
|
10
|
-
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
11
|
-
<!-- scitex-badges:end -->
|
|
12
|
-
|
|
13
3
|
<p align="center">
|
|
14
4
|
<a href="https://scitex.ai">
|
|
15
5
|
<img src="docs/scitex-logo-blue-cropped.png" alt="SciTeX" width="400">
|
|
@@ -22,6 +12,18 @@
|
|
|
22
12
|
<a href="https://scitex-git.readthedocs.io/">Full Documentation</a> · <code>pip install scitex-git</code>
|
|
23
13
|
</p>
|
|
24
14
|
|
|
15
|
+
<!-- scitex-badges:start -->
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/v/scitex-git.svg" alt="PyPI"></a>
|
|
18
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/pyversions/scitex-git.svg" alt="Python"></a>
|
|
19
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
|
|
20
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml/badge.svg" alt="Install Test"></a>
|
|
21
|
+
<a href="https://codecov.io/gh/ywatanabe1989/scitex-git"><img src="https://codecov.io/gh/ywatanabe1989/scitex-git/graph/badge.svg" alt="Coverage"></a>
|
|
22
|
+
<a href="https://scitex-git.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/scitex-git/badge/?version=latest" alt="Docs"></a>
|
|
23
|
+
<a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/license-AGPL_v3-blue.svg" alt="License: AGPL v3"></a>
|
|
24
|
+
</p>
|
|
25
|
+
<!-- scitex-badges:end -->
|
|
26
|
+
|
|
25
27
|
---
|
|
26
28
|
|
|
27
29
|
## Installation
|
|
@@ -30,19 +32,29 @@
|
|
|
30
32
|
pip install scitex-git
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
##
|
|
35
|
+
## Architecture
|
|
34
36
|
|
|
35
|
-
```python
|
|
36
|
-
import scitex_git as sxg
|
|
37
|
-
|
|
38
|
-
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
39
|
-
sxg.git_add_all("./bar")
|
|
40
|
-
sxg.git_commit("./bar", message="initial")
|
|
41
37
|
```
|
|
38
|
+
scitex_git/
|
|
39
|
+
├── _clone.py ← clone_repo, ls_remote, get_remote_url
|
|
40
|
+
├── _init.py ← git_init, init_git_repo, find_parent_git
|
|
41
|
+
├── _commit.py ← git_add_all, git_commit
|
|
42
|
+
├── _branch.py ← checkout_new_branch, branch_rename, setup_branches
|
|
43
|
+
├── _remote.py ← remote-URL helpers, head-hash queries
|
|
44
|
+
├── _retry.py ← @git_retry decorator (transient-error backoff)
|
|
45
|
+
├── _validation.py ← repo-state guards
|
|
46
|
+
├── _workflow.py ← high-level multi-step flows
|
|
47
|
+
├── _vendor_sh.py ← ~70-LOC subprocess wrapper (replaces scitex.sh)
|
|
48
|
+
└── _skills/ ← agent-facing skill pages
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Pure-stdlib core. `_vendor_sh.py` is intentionally tiny so the package
|
|
52
|
+
has no `scitex.*` runtime dependency. The umbrella `scitex.git` import
|
|
53
|
+
resolves through a `sys.modules` bridge.
|
|
42
54
|
|
|
43
55
|
## 1 Interfaces
|
|
44
56
|
|
|
45
|
-
<details>
|
|
57
|
+
<details open>
|
|
46
58
|
<summary><strong>Python API</strong></summary>
|
|
47
59
|
|
|
48
60
|
<br>
|
|
@@ -82,6 +94,34 @@ def maybe_flaky_operation(): ...
|
|
|
82
94
|
|
|
83
95
|
</details>
|
|
84
96
|
|
|
97
|
+
## Demo
|
|
98
|
+
|
|
99
|
+
```mermaid
|
|
100
|
+
flowchart LR
|
|
101
|
+
A["scitex_git.clone_repo<br/>(url, dest)"] --> B["@git_retry<br/>(transient errors)"]
|
|
102
|
+
B --> C["repo on disk"]
|
|
103
|
+
C --> D["git_add_all + git_commit"]
|
|
104
|
+
D --> E["checkout_new_branch<br/>+ branch_rename"]
|
|
105
|
+
E --> F["get_remote_url /<br/>get_head_hash"]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
>>> import scitex_git as sxg
|
|
110
|
+
>>> sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
111
|
+
>>> sxg.git_add_all("./bar")
|
|
112
|
+
>>> sxg.git_commit("./bar", message="initial")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Quick Start
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
import scitex_git as sxg
|
|
119
|
+
|
|
120
|
+
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
121
|
+
sxg.git_add_all("./bar")
|
|
122
|
+
sxg.git_commit("./bar", message="initial")
|
|
123
|
+
```
|
|
124
|
+
|
|
85
125
|
## Status
|
|
86
126
|
|
|
87
127
|
Standalone fork of `scitex.git`. `scitex.logging.getLogger` is replaced by stdlib
|
|
@@ -96,7 +136,9 @@ The umbrella package's `scitex.git` import path is preserved via a
|
|
|
96
136
|
|
|
97
137
|
## Part of SciTeX
|
|
98
138
|
|
|
99
|
-
`scitex-git` is part of [**SciTeX**](https://scitex.ai).
|
|
139
|
+
`scitex-git` is part of [**SciTeX**](https://scitex.ai). Install via
|
|
140
|
+
the umbrella with `pip install scitex[git]` to use as
|
|
141
|
+
`scitex.git` (Python) or `scitex git ...` (CLI).
|
|
100
142
|
|
|
101
143
|
>Four Freedoms for Research
|
|
102
144
|
>
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scitex-git"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Git
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Git + GitHub Actions utilities (clone, branch, commit, retry, remote helpers, gh secrets/variables with SHA256 sidecar) — standalone module from the SciTeX ecosystem"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "AGPL-3.0-only"
|
|
11
11
|
requires-python = ">=3.9"
|
|
@@ -31,6 +31,7 @@ dev = [
|
|
|
31
31
|
"pytest",
|
|
32
32
|
"pytest-cov",
|
|
33
33
|
"ruff",
|
|
34
|
+
"scitex-dev>=0.11.5",
|
|
34
35
|
]
|
|
35
36
|
docs = [
|
|
36
37
|
"sphinx>=7.0",
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
try:
|
|
9
|
-
from importlib.metadata import
|
|
9
|
+
from importlib.metadata import PackageNotFoundError
|
|
10
|
+
from importlib.metadata import version as _v
|
|
11
|
+
|
|
10
12
|
try:
|
|
11
13
|
__version__ = _v("scitex-git")
|
|
12
14
|
except PackageNotFoundError:
|
|
@@ -17,6 +19,17 @@ except ImportError: # pragma: no cover — only on ancient Pythons
|
|
|
17
19
|
from ._branch import git_branch_rename, git_checkout_new_branch
|
|
18
20
|
from ._clone import clone_repo, git_init
|
|
19
21
|
from ._commit import git_add_all, git_commit
|
|
22
|
+
from ._gh_secrets import (
|
|
23
|
+
GhSecretError,
|
|
24
|
+
format_age,
|
|
25
|
+
get_secret_metadata,
|
|
26
|
+
get_variable,
|
|
27
|
+
list_secrets,
|
|
28
|
+
set_secret,
|
|
29
|
+
set_secret_with_sha_sidecar,
|
|
30
|
+
set_variable,
|
|
31
|
+
sha256_hex,
|
|
32
|
+
)
|
|
20
33
|
from ._init import create_child_git, find_parent_git, init_git_repo, remove_child_git
|
|
21
34
|
from ._remote import get_head_hash, get_remote_url, is_cloned_from, ls_remote
|
|
22
35
|
from ._retry import git_retry
|
|
@@ -40,6 +53,16 @@ __all__ = [
|
|
|
40
53
|
"get_head_hash",
|
|
41
54
|
"setup_branches",
|
|
42
55
|
"git_retry",
|
|
56
|
+
# GitHub Actions secrets / variables
|
|
57
|
+
"GhSecretError",
|
|
58
|
+
"set_secret",
|
|
59
|
+
"list_secrets",
|
|
60
|
+
"get_secret_metadata",
|
|
61
|
+
"set_variable",
|
|
62
|
+
"get_variable",
|
|
63
|
+
"set_secret_with_sha_sidecar",
|
|
64
|
+
"sha256_hex",
|
|
65
|
+
"format_age",
|
|
43
66
|
]
|
|
44
67
|
|
|
45
68
|
# EOF
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# File: /home/ywatanabe/proj/scitex-git/src/scitex_git/_gh_secrets.py
|
|
3
|
+
|
|
4
|
+
"""GitHub Actions secrets / variables — thin wrappers around ``gh`` CLI.
|
|
5
|
+
|
|
6
|
+
The GitHub Actions REST API (and ``gh secret``) is **write-only** for
|
|
7
|
+
secret values: you can list names + ``updated_at``, but never read a
|
|
8
|
+
value back. This module bundles the everyday read/write primitives any
|
|
9
|
+
"rotate the CI key" workflow needs, plus a SHA256 sidecar pattern to
|
|
10
|
+
detect drift between local and remote without exposing the secret:
|
|
11
|
+
|
|
12
|
+
* :func:`set_secret` / :func:`list_secrets` /
|
|
13
|
+
:func:`get_secret_metadata` — direct ``gh secret`` wrappers.
|
|
14
|
+
* :func:`set_variable` / :func:`get_variable` — ``gh variable``
|
|
15
|
+
wrappers (variables are world-readable; suitable for non-sensitive
|
|
16
|
+
fingerprints, never for token material).
|
|
17
|
+
* :func:`set_secret_with_sha_sidecar` — pushes the secret AND a
|
|
18
|
+
SHA256 fingerprint to a same-name ``…_SHA256`` repo variable so a
|
|
19
|
+
later ``get_variable`` call lets the operator tell whether the
|
|
20
|
+
GitHub-side secret matches the local one. Hash is irreversible.
|
|
21
|
+
* :func:`format_age` — render an ISO-8601 ``updated_at`` as a
|
|
22
|
+
human-readable single-unit age (``15min`` / ``2.4d``) for CLI
|
|
23
|
+
reports.
|
|
24
|
+
* :func:`sha256_hex` — same hashing function the sidecar uses, so
|
|
25
|
+
callers can compute a local fingerprint to compare against
|
|
26
|
+
:func:`get_variable`.
|
|
27
|
+
|
|
28
|
+
The ``gh`` CLI must be authenticated. Each helper raises
|
|
29
|
+
:class:`GhSecretError` on subprocess failure with the underlying stderr
|
|
30
|
+
attached, so callers can surface a clean message rather than a stack
|
|
31
|
+
trace.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from __future__ import annotations
|
|
35
|
+
|
|
36
|
+
import hashlib
|
|
37
|
+
import json
|
|
38
|
+
import subprocess
|
|
39
|
+
from datetime import datetime, timezone
|
|
40
|
+
from logging import getLogger
|
|
41
|
+
|
|
42
|
+
logger = getLogger(__name__)
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"GhSecretError",
|
|
46
|
+
"set_secret",
|
|
47
|
+
"list_secrets",
|
|
48
|
+
"get_secret_metadata",
|
|
49
|
+
"set_variable",
|
|
50
|
+
"get_variable",
|
|
51
|
+
"set_secret_with_sha_sidecar",
|
|
52
|
+
"format_age",
|
|
53
|
+
"sha256_hex",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class GhSecretError(RuntimeError):
|
|
58
|
+
"""Raised when a ``gh`` subprocess returns non-zero."""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _run(argv: list[str], *, stdin: str | None = None) -> str:
|
|
62
|
+
"""Run ``argv`` and return stdout. Raise :class:`GhSecretError` on failure."""
|
|
63
|
+
proc = subprocess.run(
|
|
64
|
+
argv,
|
|
65
|
+
input=stdin,
|
|
66
|
+
text=True,
|
|
67
|
+
capture_output=True,
|
|
68
|
+
)
|
|
69
|
+
if proc.returncode != 0:
|
|
70
|
+
msg = proc.stderr.strip() or proc.stdout.strip() or "unknown error"
|
|
71
|
+
raise GhSecretError(f"{' '.join(argv[:3])}…: {msg}")
|
|
72
|
+
return proc.stdout
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# ---------------------------------------------------------------------------
|
|
76
|
+
# Secrets
|
|
77
|
+
# ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def set_secret(repo: str, name: str, value: str) -> None:
|
|
81
|
+
"""Push ``value`` into the Actions secret ``name`` for ``repo``.
|
|
82
|
+
|
|
83
|
+
``repo`` follows the ``owner/repo`` form. Idempotent — creates if
|
|
84
|
+
missing, updates otherwise.
|
|
85
|
+
"""
|
|
86
|
+
_run(["gh", "secret", "set", name, "-R", repo, "--body", "-"], stdin=value)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def list_secrets(repo: str) -> dict[str, str]:
|
|
90
|
+
"""Return ``{secret_name: updated_at_iso}`` for the repo.
|
|
91
|
+
|
|
92
|
+
Pagination is honoured (``--paginate``) so this scales beyond
|
|
93
|
+
GitHub's 100-secret default page size.
|
|
94
|
+
"""
|
|
95
|
+
raw = _run(["gh", "api", f"repos/{repo}/actions/secrets", "--paginate"])
|
|
96
|
+
payload = json.loads(raw)
|
|
97
|
+
return {s["name"]: s["updated_at"] for s in payload.get("secrets", [])}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def get_secret_metadata(repo: str, name: str) -> dict | None:
|
|
101
|
+
"""Return the secret's metadata dict (name / created_at / updated_at), or None.
|
|
102
|
+
|
|
103
|
+
GitHub never exposes the value itself — that's the whole point of
|
|
104
|
+
Actions secrets. Use :func:`get_variable` against a SHA sidecar
|
|
105
|
+
(see :func:`set_secret_with_sha_sidecar`) if you need to detect
|
|
106
|
+
value drift.
|
|
107
|
+
"""
|
|
108
|
+
proc = subprocess.run(
|
|
109
|
+
["gh", "api", f"repos/{repo}/actions/secrets/{name}"],
|
|
110
|
+
text=True,
|
|
111
|
+
capture_output=True,
|
|
112
|
+
)
|
|
113
|
+
if proc.returncode != 0:
|
|
114
|
+
return None
|
|
115
|
+
try:
|
|
116
|
+
return json.loads(proc.stdout)
|
|
117
|
+
except json.JSONDecodeError:
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# ---------------------------------------------------------------------------
|
|
122
|
+
# Variables (world-readable)
|
|
123
|
+
# ---------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def set_variable(repo: str, name: str, value: str) -> None:
|
|
127
|
+
"""Create-or-update an Actions variable. Idempotent.
|
|
128
|
+
|
|
129
|
+
Variables are visible to anyone with repo read access. Use this
|
|
130
|
+
for non-sensitive metadata (e.g. SHA256 fingerprints of secrets,
|
|
131
|
+
feature flags). NEVER store token material here.
|
|
132
|
+
"""
|
|
133
|
+
_run(["gh", "variable", "set", name, "-R", repo, "--body", value])
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def get_variable(repo: str, name: str) -> str | None:
|
|
137
|
+
"""Return the variable's value, or None if absent."""
|
|
138
|
+
proc = subprocess.run(
|
|
139
|
+
["gh", "api", f"repos/{repo}/actions/variables/{name}"],
|
|
140
|
+
text=True,
|
|
141
|
+
capture_output=True,
|
|
142
|
+
)
|
|
143
|
+
if proc.returncode != 0:
|
|
144
|
+
return None
|
|
145
|
+
try:
|
|
146
|
+
return json.loads(proc.stdout).get("value")
|
|
147
|
+
except json.JSONDecodeError:
|
|
148
|
+
return None
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# ---------------------------------------------------------------------------
|
|
152
|
+
# SHA256 sidecar — secret-drift detection without exposing the value
|
|
153
|
+
# ---------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def sha256_hex(value: str) -> str:
|
|
157
|
+
"""Return the SHA256 hex digest of ``value`` (UTF-8)."""
|
|
158
|
+
return hashlib.sha256(value.encode("utf-8")).hexdigest()
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def set_secret_with_sha_sidecar(
|
|
162
|
+
repo: str, name: str, value: str, *, sidecar_suffix: str = "_SHA256"
|
|
163
|
+
) -> str:
|
|
164
|
+
"""Push the secret AND its SHA256 fingerprint as a public variable.
|
|
165
|
+
|
|
166
|
+
Returns the SHA256 hex digest so the caller can show it in CLI
|
|
167
|
+
output. The sidecar variable is named ``{name}{sidecar_suffix}`` and
|
|
168
|
+
holds the irreversible hash; later
|
|
169
|
+
``get_variable(repo, f"{name}{sidecar_suffix}")`` lets you tell
|
|
170
|
+
whether the GitHub-side secret matches a local value (compare with
|
|
171
|
+
``sha256_hex(local_value)``).
|
|
172
|
+
|
|
173
|
+
The hash itself is not sensitive — it cannot be reversed to the
|
|
174
|
+
original token without a brute-force search of the OAuth/api-key
|
|
175
|
+
namespace, which is computationally infeasible. It IS visible to
|
|
176
|
+
repo readers, so don't use the sidecar for tokens whose mere
|
|
177
|
+
existence is sensitive (the hash leaks "this token was rotated at
|
|
178
|
+
{time} to a value with hash {h}" but never the value).
|
|
179
|
+
"""
|
|
180
|
+
digest = sha256_hex(value)
|
|
181
|
+
set_secret(repo, name, value)
|
|
182
|
+
set_variable(repo, f"{name}{sidecar_suffix}", digest)
|
|
183
|
+
return digest
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# ---------------------------------------------------------------------------
|
|
187
|
+
# Display helpers
|
|
188
|
+
# ---------------------------------------------------------------------------
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def format_age(updated_iso: str | None) -> str:
|
|
192
|
+
"""Render an ISO-8601 timestamp as a single-unit human age.
|
|
193
|
+
|
|
194
|
+
Picks the largest unit that gives a readable number: seconds for
|
|
195
|
+
very fresh rotations, then minutes, hours, days. Mirrors the
|
|
196
|
+
``git relative_date`` style — a single value + unit, no compound
|
|
197
|
+
"1d 4h" form. Returns ``"?"`` for ``None`` input.
|
|
198
|
+
|
|
199
|
+
>>> format_age(None)
|
|
200
|
+
'?'
|
|
201
|
+
"""
|
|
202
|
+
if not updated_iso:
|
|
203
|
+
return "?"
|
|
204
|
+
dt = datetime.fromisoformat(updated_iso.replace("Z", "+00:00"))
|
|
205
|
+
seconds = (datetime.now(timezone.utc) - dt).total_seconds()
|
|
206
|
+
if seconds < 60:
|
|
207
|
+
return f"{int(seconds)}s"
|
|
208
|
+
if seconds < 3600:
|
|
209
|
+
return f"{int(seconds / 60)}min"
|
|
210
|
+
if seconds < 86400:
|
|
211
|
+
return f"{seconds / 3600:.1f}h"
|
|
212
|
+
return f"{seconds / 86400:.1f}d"
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
# EOF
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: |
|
|
3
|
+
[TOPIC] Installation
|
|
4
|
+
[DETAILS] pip install scitex-git. Pure-Python wrapper around the system `git` binary; you must have `git` installed on PATH.
|
|
5
|
+
tags: [scitex-git-installation]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Installation
|
|
9
|
+
|
|
10
|
+
## Standard
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install scitex-git
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Pure-Python; no Python deps. Wraps the system `git` binary via `subprocess`.
|
|
17
|
+
|
|
18
|
+
## Required system tool
|
|
19
|
+
|
|
20
|
+
| Tool | Install |
|
|
21
|
+
|--------|----------------------------------------------------------|
|
|
22
|
+
| `git` | `apt install git` / `brew install git` / https://git-scm.com/ |
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git --version # must be on PATH
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Verify
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python -c "import scitex_git; print(scitex_git.__version__)"
|
|
32
|
+
python -c "from scitex_git import clone_repo, git_init, git_commit, git_retry; print('ok')"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Editable install (development)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/ywatanabe1989/scitex-git
|
|
39
|
+
cd scitex-git
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Used by
|
|
44
|
+
|
|
45
|
+
Pulled in transitively by ecosystem packages that need programmatic git
|
|
46
|
+
operations (e.g. scitex-cloud's three-way sync, project scaffolding).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: |
|
|
3
|
+
[TOPIC] Quick start
|
|
4
|
+
[DETAILS] Clone, init, commit, branch, retry — the smallest useful examples for the most-used helpers.
|
|
5
|
+
tags: [scitex-git-quick-start]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Quick Start
|
|
9
|
+
|
|
10
|
+
## Clone
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from scitex_git import clone_repo
|
|
14
|
+
|
|
15
|
+
clone_repo("https://github.com/u/r.git", dest="/tmp/r")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Init + first commit
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from scitex_git import git_init, git_add_all, git_commit
|
|
22
|
+
|
|
23
|
+
git_init("/tmp/new-repo")
|
|
24
|
+
git_add_all("/tmp/new-repo")
|
|
25
|
+
git_commit("/tmp/new-repo", message="initial commit")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Branches
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from scitex_git import git_checkout_new_branch, git_branch_rename, setup_branches
|
|
32
|
+
|
|
33
|
+
git_checkout_new_branch("/tmp/r", "feature/x")
|
|
34
|
+
git_branch_rename("/tmp/r", old="master", new="main")
|
|
35
|
+
setup_branches("/tmp/r", main="main", develop="develop")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Discover parent + remote
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from scitex_git import find_parent_git, get_remote_url, is_cloned_from
|
|
42
|
+
|
|
43
|
+
root = find_parent_git("/tmp/r/sub/dir") # walks up to .git/
|
|
44
|
+
url = get_remote_url("/tmp/r")
|
|
45
|
+
is_cloned_from("/tmp/r", "https://github.com/u/r.git")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Retry transient failures
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from scitex_git import git_retry
|
|
52
|
+
|
|
53
|
+
git_retry(["push"], cwd="/tmp/r", attempts=3)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Next
|
|
57
|
+
|
|
58
|
+
- [03_python-api.md](03_python-api.md) — full public surface
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: |
|
|
3
|
+
[TOPIC] Python API
|
|
4
|
+
[DETAILS] Public callables — clone/init, commit, branches, parent-git discovery, remote inspection, retry, workflow setup.
|
|
5
|
+
tags: [scitex-git-python-api]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Python API
|
|
9
|
+
|
|
10
|
+
## Imports
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from scitex_git import (
|
|
14
|
+
# clone + init
|
|
15
|
+
clone_repo, git_init,
|
|
16
|
+
# commit
|
|
17
|
+
git_add_all, git_commit,
|
|
18
|
+
# branches
|
|
19
|
+
git_branch_rename, git_checkout_new_branch,
|
|
20
|
+
# init / parent discovery
|
|
21
|
+
create_child_git, find_parent_git, init_git_repo, remove_child_git,
|
|
22
|
+
# remote inspection
|
|
23
|
+
get_head_hash, get_remote_url, is_cloned_from, ls_remote,
|
|
24
|
+
# retry
|
|
25
|
+
git_retry,
|
|
26
|
+
# composite workflow
|
|
27
|
+
setup_branches,
|
|
28
|
+
)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Clone + init
|
|
32
|
+
|
|
33
|
+
| Callable | Purpose |
|
|
34
|
+
|---------------------------------------|------------------------------------------|
|
|
35
|
+
| `clone_repo(url, dest, ...)` | Clone a remote |
|
|
36
|
+
| `git_init(path)` | `git init` at a path |
|
|
37
|
+
| `init_git_repo(path)` | Init + sensible defaults |
|
|
38
|
+
| `create_child_git(parent, child)` | Add a nested git repo |
|
|
39
|
+
| `remove_child_git(child)` | Remove a nested git repo cleanly |
|
|
40
|
+
|
|
41
|
+
## Commit
|
|
42
|
+
|
|
43
|
+
| Callable | Purpose |
|
|
44
|
+
|---------------------------------------|------------------------------------------|
|
|
45
|
+
| `git_add_all(path)` | `git add -A` |
|
|
46
|
+
| `git_commit(path, message=...)` | `git commit -m` |
|
|
47
|
+
|
|
48
|
+
## Branches
|
|
49
|
+
|
|
50
|
+
| Callable | Purpose |
|
|
51
|
+
|---------------------------------------|------------------------------------------|
|
|
52
|
+
| `git_checkout_new_branch(path, name)` | `git checkout -b` |
|
|
53
|
+
| `git_branch_rename(path, old, new)` | Rename a branch |
|
|
54
|
+
| `setup_branches(path, main, develop)` | Create a main/develop topology |
|
|
55
|
+
|
|
56
|
+
## Discovery + inspection
|
|
57
|
+
|
|
58
|
+
| Callable | Purpose |
|
|
59
|
+
|---------------------------------------|------------------------------------------|
|
|
60
|
+
| `find_parent_git(path)` | Walk up to enclosing `.git/` |
|
|
61
|
+
| `get_remote_url(path, name="origin")` | Fetch the remote URL |
|
|
62
|
+
| `get_head_hash(path)` | HEAD commit SHA |
|
|
63
|
+
| `is_cloned_from(path, url)` | True if origin matches |
|
|
64
|
+
| `ls_remote(url)` | List remote refs without cloning |
|
|
65
|
+
|
|
66
|
+
## Retry
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
git_retry(["push"], cwd=".", attempts=3, backoff=2.0)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Wraps any `git` subcommand in exponential backoff for transient network
|
|
73
|
+
failures.
|
|
74
|
+
|
|
75
|
+
## Notes
|
|
76
|
+
|
|
77
|
+
All callables return either `None` or stdout-as-str; failures raise
|
|
78
|
+
`subprocess.CalledProcessError` (or a subclass).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scitex-git
|
|
3
|
+
description: |
|
|
4
|
+
[WHAT] Programmatic git operations — clone/init/commit/branch/remote/retry helpers (`clone_repo`, `git_init`, `git_commit`, `git_branch_rename`, `find_parent_git`, `get_remote_url`, `is_cloned_from`, `git_retry`, `setup_branches`, ...).
|
|
5
|
+
[WHEN] Automating git workflows from Python without shelling out and parsing stdout — repo init, commits, branch setup, parent-git discovery.
|
|
6
|
+
[HOW] `from scitex_git import clone_repo, git_init, git_commit, git_add_all, git_retry, ...` — wraps subprocess `git`.
|
|
7
|
+
tags: [scitex-git]
|
|
8
|
+
primary_interface: python
|
|
9
|
+
interfaces:
|
|
10
|
+
python: 3
|
|
11
|
+
cli: 0
|
|
12
|
+
mcp: 0
|
|
13
|
+
skills: 2
|
|
14
|
+
http: 0
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
> **Interfaces:** Python ⭐⭐⭐ · CLI — · MCP — · Skills ⭐⭐ · Hook — · HTTP —
|
|
18
|
+
|
|
19
|
+
# scitex-git
|
|
20
|
+
|
|
21
|
+
Programmatic git operations — `clone_repo`, `git_init`, `git_commit`, `git_add_all`, `git_branch_rename`, `git_checkout_new_branch`, `find_parent_git`, `init_git_repo`, `get_remote_url`, `is_cloned_from`, `git_retry`, `setup_branches`. Drop-in replacement for shelling out to `git` via `subprocess.run` and parsing stdout.
|
|
22
|
+
|
|
23
|
+
## Sub-skills
|
|
24
|
+
|
|
25
|
+
- [01_installation.md](01_installation.md) — pip install + system `git` requirement
|
|
26
|
+
- [02_quick-start.md](02_quick-start.md) — clone, init, commit, branch, retry
|
|
27
|
+
- [03_python-api.md](03_python-api.md) — full public surface
|
|
28
|
+
|
|
29
|
+
See README.md and the package's public `__init__.py` for the full
|
|
30
|
+
function list.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scitex-git
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Git
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Git + GitHub Actions utilities (clone, branch, commit, retry, remote helpers, gh secrets/variables with SHA256 sidecar) — standalone module from the SciTeX ecosystem
|
|
5
5
|
Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
|
|
6
6
|
License-Expression: AGPL-3.0-only
|
|
7
7
|
Project-URL: Homepage, https://github.com/ywatanabe1989/scitex-git
|
|
@@ -25,6 +25,7 @@ Provides-Extra: dev
|
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
26
26
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
27
27
|
Requires-Dist: ruff; extra == "dev"
|
|
28
|
+
Requires-Dist: scitex-dev>=0.11.5; extra == "dev"
|
|
28
29
|
Provides-Extra: docs
|
|
29
30
|
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
30
31
|
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
|
|
@@ -37,16 +38,6 @@ Dynamic: license-file
|
|
|
37
38
|
|
|
38
39
|
# scitex-git
|
|
39
40
|
|
|
40
|
-
<!-- scitex-badges:start -->
|
|
41
|
-
[](https://pypi.org/project/scitex-git/)
|
|
42
|
-
[](https://pypi.org/project/scitex-git/)
|
|
43
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml)
|
|
44
|
-
[](https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml)
|
|
45
|
-
[](https://codecov.io/gh/ywatanabe1989/scitex-git)
|
|
46
|
-
[](https://scitex-git.readthedocs.io/en/latest/)
|
|
47
|
-
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
48
|
-
<!-- scitex-badges:end -->
|
|
49
|
-
|
|
50
41
|
<p align="center">
|
|
51
42
|
<a href="https://scitex.ai">
|
|
52
43
|
<img src="docs/scitex-logo-blue-cropped.png" alt="SciTeX" width="400">
|
|
@@ -59,6 +50,18 @@ Dynamic: license-file
|
|
|
59
50
|
<a href="https://scitex-git.readthedocs.io/">Full Documentation</a> · <code>pip install scitex-git</code>
|
|
60
51
|
</p>
|
|
61
52
|
|
|
53
|
+
<!-- scitex-badges:start -->
|
|
54
|
+
<p align="center">
|
|
55
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/v/scitex-git.svg" alt="PyPI"></a>
|
|
56
|
+
<a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/pyversions/scitex-git.svg" alt="Python"></a>
|
|
57
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
|
|
58
|
+
<a href="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml"><img src="https://github.com/ywatanabe1989/scitex-git/actions/workflows/install-test.yml/badge.svg" alt="Install Test"></a>
|
|
59
|
+
<a href="https://codecov.io/gh/ywatanabe1989/scitex-git"><img src="https://codecov.io/gh/ywatanabe1989/scitex-git/graph/badge.svg" alt="Coverage"></a>
|
|
60
|
+
<a href="https://scitex-git.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/scitex-git/badge/?version=latest" alt="Docs"></a>
|
|
61
|
+
<a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/license-AGPL_v3-blue.svg" alt="License: AGPL v3"></a>
|
|
62
|
+
</p>
|
|
63
|
+
<!-- scitex-badges:end -->
|
|
64
|
+
|
|
62
65
|
---
|
|
63
66
|
|
|
64
67
|
## Installation
|
|
@@ -67,19 +70,29 @@ Dynamic: license-file
|
|
|
67
70
|
pip install scitex-git
|
|
68
71
|
```
|
|
69
72
|
|
|
70
|
-
##
|
|
73
|
+
## Architecture
|
|
71
74
|
|
|
72
|
-
```python
|
|
73
|
-
import scitex_git as sxg
|
|
74
|
-
|
|
75
|
-
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
76
|
-
sxg.git_add_all("./bar")
|
|
77
|
-
sxg.git_commit("./bar", message="initial")
|
|
78
75
|
```
|
|
76
|
+
scitex_git/
|
|
77
|
+
├── _clone.py ← clone_repo, ls_remote, get_remote_url
|
|
78
|
+
├── _init.py ← git_init, init_git_repo, find_parent_git
|
|
79
|
+
├── _commit.py ← git_add_all, git_commit
|
|
80
|
+
├── _branch.py ← checkout_new_branch, branch_rename, setup_branches
|
|
81
|
+
├── _remote.py ← remote-URL helpers, head-hash queries
|
|
82
|
+
├── _retry.py ← @git_retry decorator (transient-error backoff)
|
|
83
|
+
├── _validation.py ← repo-state guards
|
|
84
|
+
├── _workflow.py ← high-level multi-step flows
|
|
85
|
+
├── _vendor_sh.py ← ~70-LOC subprocess wrapper (replaces scitex.sh)
|
|
86
|
+
└── _skills/ ← agent-facing skill pages
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Pure-stdlib core. `_vendor_sh.py` is intentionally tiny so the package
|
|
90
|
+
has no `scitex.*` runtime dependency. The umbrella `scitex.git` import
|
|
91
|
+
resolves through a `sys.modules` bridge.
|
|
79
92
|
|
|
80
93
|
## 1 Interfaces
|
|
81
94
|
|
|
82
|
-
<details>
|
|
95
|
+
<details open>
|
|
83
96
|
<summary><strong>Python API</strong></summary>
|
|
84
97
|
|
|
85
98
|
<br>
|
|
@@ -119,6 +132,34 @@ def maybe_flaky_operation(): ...
|
|
|
119
132
|
|
|
120
133
|
</details>
|
|
121
134
|
|
|
135
|
+
## Demo
|
|
136
|
+
|
|
137
|
+
```mermaid
|
|
138
|
+
flowchart LR
|
|
139
|
+
A["scitex_git.clone_repo<br/>(url, dest)"] --> B["@git_retry<br/>(transient errors)"]
|
|
140
|
+
B --> C["repo on disk"]
|
|
141
|
+
C --> D["git_add_all + git_commit"]
|
|
142
|
+
D --> E["checkout_new_branch<br/>+ branch_rename"]
|
|
143
|
+
E --> F["get_remote_url /<br/>get_head_hash"]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
>>> import scitex_git as sxg
|
|
148
|
+
>>> sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
149
|
+
>>> sxg.git_add_all("./bar")
|
|
150
|
+
>>> sxg.git_commit("./bar", message="initial")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Quick Start
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
import scitex_git as sxg
|
|
157
|
+
|
|
158
|
+
sxg.clone_repo("https://github.com/foo/bar", "./bar")
|
|
159
|
+
sxg.git_add_all("./bar")
|
|
160
|
+
sxg.git_commit("./bar", message="initial")
|
|
161
|
+
```
|
|
162
|
+
|
|
122
163
|
## Status
|
|
123
164
|
|
|
124
165
|
Standalone fork of `scitex.git`. `scitex.logging.getLogger` is replaced by stdlib
|
|
@@ -133,7 +174,9 @@ The umbrella package's `scitex.git` import path is preserved via a
|
|
|
133
174
|
|
|
134
175
|
## Part of SciTeX
|
|
135
176
|
|
|
136
|
-
`scitex-git` is part of [**SciTeX**](https://scitex.ai).
|
|
177
|
+
`scitex-git` is part of [**SciTeX**](https://scitex.ai). Install via
|
|
178
|
+
the umbrella with `pip install scitex[git]` to use as
|
|
179
|
+
`scitex.git` (Python) or `scitex git ...` (CLI).
|
|
137
180
|
|
|
138
181
|
>Four Freedoms for Research
|
|
139
182
|
>
|
|
@@ -6,6 +6,7 @@ src/scitex_git/_branch.py
|
|
|
6
6
|
src/scitex_git/_clone.py
|
|
7
7
|
src/scitex_git/_commit.py
|
|
8
8
|
src/scitex_git/_constants.py
|
|
9
|
+
src/scitex_git/_gh_secrets.py
|
|
9
10
|
src/scitex_git/_init.py
|
|
10
11
|
src/scitex_git/_remote.py
|
|
11
12
|
src/scitex_git/_result.py
|
|
@@ -21,4 +22,7 @@ src/scitex_git.egg-info/dependency_links.txt
|
|
|
21
22
|
src/scitex_git.egg-info/entry_points.txt
|
|
22
23
|
src/scitex_git.egg-info/requires.txt
|
|
23
24
|
src/scitex_git.egg-info/top_level.txt
|
|
25
|
+
src/scitex_git/_skills/scitex-git/01_installation.md
|
|
26
|
+
src/scitex_git/_skills/scitex-git/02_quick-start.md
|
|
27
|
+
src/scitex_git/_skills/scitex-git/03_python-api.md
|
|
24
28
|
src/scitex_git/_skills/scitex-git/SKILL.md
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: scitex-git
|
|
3
|
-
description: Programmatic git operations — `clone_repo`, `git_init`, `git_commit`, `git_add_all`, `git_branch_rename`, `git_checkout_new_branch`, `find_parent_git`, `init_git_repo`, `get_remote_url`, `is_cloned_from`, `git_retry`, `setup_branches`. Drop-in replacement for shelling out to `git` via `subprocess.run` and parsing stdout.
|
|
4
|
-
primary_interface: python
|
|
5
|
-
interfaces:
|
|
6
|
-
python: 3
|
|
7
|
-
cli: 1
|
|
8
|
-
mcp: 0
|
|
9
|
-
skills: 2
|
|
10
|
-
hook: 0
|
|
11
|
-
http: 0
|
|
12
|
-
canonical-location: scitex-git/src/scitex_git/_skills/scitex-git/SKILL.md
|
|
13
|
-
tags: [scitex-git, scitex-package]
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
> **Interfaces:** Python ⭐⭐⭐ · CLI ⭐ · MCP — · Skills ⭐⭐ · Hook — · HTTP —
|
|
17
|
-
|
|
18
|
-
# scitex-git
|
|
19
|
-
|
|
20
|
-
Programmatic git operations — `clone_repo`, `git_init`, `git_commit`, `git_add_all`, `git_branch_rename`, `git_checkout_new_branch`, `find_parent_git`, `init_git_repo`, `get_remote_url`, `is_cloned_from`, `git_retry`, `setup_branches`. Drop-in replacement for shelling out to `git` via `subprocess.run` and parsing stdout.
|
|
21
|
-
|
|
22
|
-
See README.md and the package's public `__init__.py` for the full
|
|
23
|
-
function list. This skill leaf exists so agents discover the package
|
|
24
|
-
exists and roughly what shape it has — refer to the source for
|
|
25
|
-
signatures.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|