Metadata-Version: 2.4
Name: scitex-git
Version: 0.3.1
Summary: Git + GitHub Actions utilities (clone, branch, commit, retry, remote helpers, gh secrets/variables with SHA256 sidecar) — standalone module from the SciTeX ecosystem
Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
License-Expression: AGPL-3.0-only
Project-URL: Homepage, https://github.com/ywatanabe1989/scitex-git
Project-URL: Repository, https://github.com/ywatanabe1989/scitex-git
Project-URL: Documentation, https://scitex-git.readthedocs.io
Keywords: scitex,git,gitpython,version-control,clone,commit
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: GitPython>=3.1
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: scitex-dev>=0.11.7; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == "docs"
Provides-Extra: all
Requires-Dist: scitex-git[dev,docs]; extra == "all"
Dynamic: license-file

# scitex-git

<p align="center">
  <a href="https://scitex.ai">
    <img src="docs/scitex-logo-blue-cropped.png" alt="SciTeX" width="400">
  </a>
</p>

<p align="center"><b>Git operations and utilities — clone, init, branch, remote, retry decorator.</b></p>

<p align="center">
  <a href="https://scitex-git.readthedocs.io/">Full Documentation</a> · <code>uv pip install scitex-git[all]</code>
</p>

<!-- scitex-badges:start -->
<p align="center">
  <a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/v/scitex-git.svg" alt="PyPI"></a>
  <a href="https://pypi.org/project/scitex-git/"><img src="https://img.shields.io/pypi/pyversions/scitex-git.svg" alt="Python"></a>
  <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>
  <a href="https://codecov.io/gh/ywatanabe1989/scitex-git"><img src="https://codecov.io/gh/ywatanabe1989/scitex-git/graph/badge.svg" alt="Coverage"></a>
  <a href="https://scitex-git.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/scitex-git/badge/?version=latest" alt="Docs"></a>
  <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>
</p>
<!-- scitex-badges:end -->

---

## Installation

```bash
pip install scitex-git
```

## Architecture

```
scitex_git/
├── _clone.py          ← clone_repo, ls_remote, get_remote_url
├── _init.py           ← git_init, init_git_repo, find_parent_git
├── _commit.py         ← git_add_all, git_commit
├── _branch.py         ← checkout_new_branch, branch_rename, setup_branches
├── _remote.py         ← remote-URL helpers, head-hash queries
├── _retry.py          ← @git_retry decorator (transient-error backoff)
├── _validation.py     ← repo-state guards
├── _workflow.py       ← high-level multi-step flows
├── _vendor_sh.py      ← ~70-LOC subprocess wrapper (replaces scitex.sh)
└── _skills/           ← agent-facing skill pages
```

Pure-stdlib core. `_vendor_sh.py` is intentionally tiny so the package
has no `scitex.*` runtime dependency. The umbrella `scitex.git` import
resolves through a `sys.modules` bridge.

## 1 Interfaces

<details open>
<summary><strong>Python API</strong></summary>

<br>

```python
import scitex_git as sxg

# Clone / init
sxg.clone_repo(url, dest_dir)
sxg.git_init(repo_path)

# Add / commit
sxg.git_add_all(repo_path)
sxg.git_commit(repo_path, message="…")

# Branch
sxg.git_checkout_new_branch(repo_path, branch_name)
sxg.git_branch_rename(repo_path, old, new)
sxg.setup_branches(repo_path, template_name)

# Repo init / discovery
sxg.init_git_repo(project_dir, git_strategy="parent")
sxg.find_parent_git(project_dir)
sxg.create_child_git(project_dir)
sxg.remove_child_git(project_dir)

# Remote
sxg.get_remote_url(repo_path)
sxg.is_cloned_from(repo_path, url)
sxg.ls_remote(url)
sxg.get_head_hash(repo_path)

# Retry decorator
@sxg.git_retry(max_attempts=3)
def maybe_flaky_operation(): ...
```

</details>

## Demo

```mermaid
flowchart LR
    A["scitex_git.clone_repo<br/>(url, dest)"] --> B["@git_retry<br/>(transient errors)"]
    B --> C["repo on disk"]
    C --> D["git_add_all + git_commit"]
    D --> E["checkout_new_branch<br/>+ branch_rename"]
    E --> F["get_remote_url /<br/>get_head_hash"]
```

```python
>>> import scitex_git as sxg
>>> sxg.clone_repo("https://github.com/foo/bar", "./bar")
>>> sxg.git_add_all("./bar")
>>> sxg.git_commit("./bar", message="initial")
```

## Quick Start

```python
import scitex_git as sxg

sxg.clone_repo("https://github.com/foo/bar", "./bar")
sxg.git_add_all("./bar")
sxg.git_commit("./bar", message="initial")
```

## Status

Standalone fork of `scitex.git`. `scitex.logging.getLogger` is replaced by stdlib
`logging.getLogger`; the `scitex.sh.sh` shell wrapper is replaced by a tiny
~70-LOC `_vendor_sh.py` that supports just the call-shape used here. The
optional `scitex.writer.verify_tree_structure` validation step in
`create_child_git` is gated behind a `try/except` so it only runs when
`scitex-writer` is installed.

The umbrella package's `scitex.git` import path is preserved via a
`sys.modules`-alias bridge so existing code continues to work.

## Part of SciTeX

`scitex-git` is part of [**SciTeX**](https://scitex.ai). Install via
the umbrella with `pip install scitex[git]` to use as
`scitex.git` (Python) or `scitex git ...` (CLI).

>Four Freedoms for Research
>
>0. The freedom to **run** your research anywhere — your machine, your terms.
>1. The freedom to **study** how every step works — from raw data to final manuscript.
>2. The freedom to **redistribute** your workflows, not just your papers.
>3. The freedom to **modify** any module and share improvements with the community.
>
>AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

## License

AGPL-3.0-only (see [LICENSE](./LICENSE)).

---

<p align="center">
  <a href="https://scitex.ai" target="_blank"><img src="docs/scitex-icon-navy-inverted.png" alt="SciTeX" width="40"/></a>
</p>
