scitex-git 0.3.1__tar.gz → 0.4.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 (39) hide show
  1. {scitex_git-0.3.1 → scitex_git-0.4.1}/LICENSE +1 -2
  2. {scitex_git-0.3.1/src/scitex_git.egg-info → scitex_git-0.4.1}/PKG-INFO +4 -1
  3. {scitex_git-0.3.1 → scitex_git-0.4.1}/pyproject.toml +7 -1
  4. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/__init__.py +2 -0
  5. scitex_git-0.4.1/src/scitex_git/__main__.py +7 -0
  6. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_branch.py +3 -3
  7. scitex_git-0.4.1/src/scitex_git/_cli.py +324 -0
  8. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_clone.py +3 -3
  9. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_commit.py +3 -3
  10. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_gh_secrets.py +3 -2
  11. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_init.py +2 -2
  12. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_remote.py +6 -5
  13. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_retry.py +2 -2
  14. scitex_git-0.4.1/src/scitex_git/_skills/scitex-git/04_cli-reference.md +27 -0
  15. scitex_git-0.4.1/src/scitex_git/_skills/scitex-git/05_public-mirror.md +65 -0
  16. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_skills/scitex-git/SKILL.md +5 -3
  17. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_vendor_sh.py +12 -3
  18. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_workflow.py +3 -3
  19. scitex_git-0.4.1/src/scitex_git/mirror/__init__.py +162 -0
  20. scitex_git-0.4.1/src/scitex_git/mirror/_config.py +184 -0
  21. scitex_git-0.4.1/src/scitex_git/mirror/_scan.py +197 -0
  22. scitex_git-0.4.1/src/scitex_git/mirror/_tree.py +115 -0
  23. {scitex_git-0.3.1 → scitex_git-0.4.1/src/scitex_git.egg-info}/PKG-INFO +4 -1
  24. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git.egg-info/SOURCES.txt +9 -1
  25. scitex_git-0.4.1/src/scitex_git.egg-info/entry_points.txt +5 -0
  26. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git.egg-info/requires.txt +3 -0
  27. scitex_git-0.3.1/src/scitex_git.egg-info/entry_points.txt +0 -2
  28. {scitex_git-0.3.1 → scitex_git-0.4.1}/README.md +0 -0
  29. {scitex_git-0.3.1 → scitex_git-0.4.1}/setup.cfg +0 -0
  30. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_constants.py +0 -0
  31. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_result.py +0 -0
  32. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_skills/scitex-git/01_installation.md +0 -0
  33. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_skills/scitex-git/02_quick-start.md +0 -0
  34. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_skills/scitex-git/03_python-api.md +0 -0
  35. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_types.py +0 -0
  36. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_utils.py +0 -0
  37. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git/_validation.py +0 -0
  38. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git.egg-info/dependency_links.txt +0 -0
  39. {scitex_git-0.3.1 → scitex_git-0.4.1}/src/scitex_git.egg-info/top_level.txt +0 -0
@@ -634,8 +634,7 @@ the "copyright" line and a pointer to where the full notice is found.
634
634
 
635
635
  This program is free software: you can redistribute it and/or modify
636
636
  it under the terms of the GNU Affero General Public License as published by
637
- the Free Software Foundation, either version 3 of the License, or
638
- (at your option) any later version.
637
+ the Free Software Foundation, version 3 of the License only.
639
638
 
640
639
  This program is distributed in the hope that it will be useful,
641
640
  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scitex-git
3
- Version: 0.3.1
3
+ Version: 0.4.1
4
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
@@ -21,6 +21,9 @@ Requires-Python: >=3.9
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: GitPython>=3.1
24
+ Requires-Dist: click>=8.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: scitex-logging>=0.2.5
24
27
  Provides-Extra: dev
25
28
  Requires-Dist: pytest; extra == "dev"
26
29
  Requires-Dist: pytest-cov; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scitex-git"
7
- version = "0.3.1"
7
+ version = "0.4.1"
8
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"
@@ -24,6 +24,9 @@ classifiers = [
24
24
  ]
25
25
  dependencies = [
26
26
  "GitPython>=3.1",
27
+ "click>=8.0",
28
+ "pyyaml>=6.0",
29
+ "scitex-logging>=0.2.5",
27
30
  ]
28
31
 
29
32
  [project.optional-dependencies]
@@ -44,6 +47,9 @@ all = [
44
47
  "scitex-git[dev,docs]",
45
48
  ]
46
49
 
50
+ [project.scripts]
51
+ scitex-git = "scitex_git._cli:main"
52
+
47
53
  [project.urls]
48
54
  Homepage = "https://github.com/ywatanabe1989/scitex-git"
49
55
  Repository = "https://github.com/ywatanabe1989/scitex-git"
@@ -34,9 +34,11 @@ from ._init import create_child_git, find_parent_git, init_git_repo, remove_chil
34
34
  from ._remote import get_head_hash, get_remote_url, is_cloned_from, ls_remote
35
35
  from ._retry import git_retry
36
36
  from ._workflow import setup_branches
37
+ from . import mirror
37
38
 
38
39
  __all__ = [
39
40
  "__version__",
41
+ "mirror",
40
42
  "init_git_repo",
41
43
  "find_parent_git",
42
44
  "create_child_git",
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env python3
2
+ """``python -m scitex_git`` — same as the ``scitex-git`` command."""
3
+
4
+ from ._cli import main
5
+
6
+ if __name__ == "__main__":
7
+ main()
@@ -16,14 +16,14 @@ Examples
16
16
 
17
17
  from pathlib import Path
18
18
 
19
- from logging import getLogger
20
- from ._vendor_sh import sh
19
+ import scitex_logging as slogging
21
20
 
22
21
  from ._constants import EXIT_FAILURE, EXIT_SUCCESS
23
22
  from ._utils import _in_directory
24
23
  from ._validation import validate_branch_name, validate_path
24
+ from ._vendor_sh import sh
25
25
 
26
- logger = getLogger(__name__)
26
+ logger = slogging.getLogger(__name__)
27
27
 
28
28
 
29
29
  def git_branch_rename(repo_path: Path, new_name: str, verbose: bool = True) -> bool:
@@ -0,0 +1,324 @@
1
+ #!/usr/bin/env python3
2
+ """``scitex-git`` command line.
3
+
4
+ - ``scitex-git mirror export`` — build the public tree, scan it, commit it (on a clean scan)
5
+ - ``scitex-git mirror validate`` — list tracked paths the publish config denies
6
+ - ``scitex-git list-python-apis`` — public Python API
7
+ - ``scitex-git mirror``, ``mcp list-tools`` (no MCP server)
8
+
9
+ The engine is :mod:`scitex_git.mirror`; the config is ``.scitex/git/publish.yaml``.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import json
15
+ import sys
16
+ from dataclasses import asdict
17
+ from pathlib import Path
18
+
19
+ import click
20
+
21
+
22
+ def _load(project: str, config: str | None):
23
+ from .mirror import MirrorConfigError, load_config
24
+
25
+ try:
26
+ return load_config(Path(project), Path(config) if config else None)
27
+ except MirrorConfigError as e:
28
+ raise click.ClickException(str(e)) from e
29
+
30
+
31
+ def _version() -> str:
32
+ try:
33
+ from importlib.metadata import version
34
+
35
+ return version("scitex-git")
36
+ except Exception: # pragma: no cover
37
+ return "unknown"
38
+
39
+
40
+ def _show_recursive_help(ctx: click.Context) -> None:
41
+ """Print help for the root group and every (sub)command."""
42
+
43
+ def walk(cmd: click.Command, cctx: click.Context, path: str) -> None:
44
+ click.echo("=" * 60)
45
+ click.echo(f"Command: {path}")
46
+ click.echo("=" * 60)
47
+ click.echo(cctx.get_help())
48
+ click.echo()
49
+ if isinstance(cmd, click.Group):
50
+ for name in sorted(cmd.list_commands(cctx)):
51
+ sub = cmd.get_command(cctx, name)
52
+ if sub is not None and not sub.hidden:
53
+ walk(sub, click.Context(sub, parent=cctx, info_name=name), f"{path} {name}")
54
+
55
+ walk(ctx.command, ctx, "scitex-git")
56
+
57
+
58
+ @click.group(
59
+ context_settings={"help_option_names": ["-h", "--help"]},
60
+ invoke_without_command=True,
61
+ )
62
+ @click.version_option(_version(), "-V", "--version", prog_name="scitex-git")
63
+ @click.option("--help-recursive", is_flag=True, help="Show help for all subcommands.")
64
+ @click.option("--json", "as_json", is_flag=True, help="Emit JSON (propagates to subcommands that honour it).")
65
+ @click.pass_context
66
+ def main(ctx: click.Context, help_recursive: bool, as_json: bool) -> None:
67
+ """Git and GitHub utilities from the SciTeX ecosystem.
68
+
69
+ \b
70
+ Config: <project>/.scitex/git/publish.yaml (or --config) for `mirror`;
71
+ package-level settings under ~/.scitex/git/.
72
+
73
+ \b
74
+ Example:
75
+ $ scitex-git mirror export --out /tmp/tree
76
+ """
77
+ ctx.ensure_object(dict)
78
+ ctx.obj["as_json"] = as_json
79
+ if help_recursive:
80
+ _show_recursive_help(ctx)
81
+ ctx.exit(0)
82
+ elif ctx.invoked_subcommand is None:
83
+ click.echo(ctx.get_help())
84
+
85
+
86
+ @main.group("mirror")
87
+ def mirror_grp() -> None:
88
+ """Public mirror of a private repository (config: .scitex/git/publish.yaml).
89
+
90
+ GitHub visibility is per repository, not per branch. Keep the repository
91
+ private and publish a separate public repository, exported one way with
92
+ its own history.
93
+
94
+ \b
95
+ Examples:
96
+ scitex-git mirror validate
97
+ scitex-git mirror export --out /tmp/tree
98
+ scitex-git mirror export --out /tmp/tree --public-clone ../pub --tag paper-v0.1 --push --yes
99
+ """
100
+
101
+
102
+ @mirror_grp.command("export")
103
+ @click.option(
104
+ "--project", default=".", show_default=True, help="Private repository root."
105
+ )
106
+ @click.option(
107
+ "--config",
108
+ default=None,
109
+ help="Config path (default: <project>/.scitex/git/publish.yaml).",
110
+ )
111
+ @click.option(
112
+ "--ref", default=None, help="Private commit to export (default: config 'ref')."
113
+ )
114
+ @click.option(
115
+ "--out",
116
+ required=True,
117
+ type=click.Path(),
118
+ help="New, empty directory for the export.",
119
+ )
120
+ @click.option(
121
+ "--public-clone",
122
+ default=None,
123
+ type=click.Path(),
124
+ help="Clone of the public repo to commit into.",
125
+ )
126
+ @click.option(
127
+ "--tag",
128
+ "tags",
129
+ multiple=True,
130
+ help="Annotated tag for the public commit (repeatable).",
131
+ )
132
+ @click.option(
133
+ "--push", is_flag=True, help="Push the commit and tags to the clone's origin."
134
+ )
135
+ @click.option(
136
+ "--no-leak-check", is_flag=True, help="Skip the config's leak_check command."
137
+ )
138
+ @click.option(
139
+ "--dry-run", is_flag=True, help="Build and scan only; never commit or push."
140
+ )
141
+ @click.option(
142
+ "--yes", "-y", is_flag=True, help="Required to commit (and push) to --public-clone."
143
+ )
144
+ @click.option("--json", "as_json", is_flag=True, help="Emit the result as JSON.")
145
+ def mirror_export(
146
+ project,
147
+ config,
148
+ ref,
149
+ out,
150
+ public_clone,
151
+ tags,
152
+ push,
153
+ no_leak_check,
154
+ dry_run,
155
+ yes,
156
+ as_json,
157
+ ) -> None:
158
+ """Export tracked files minus the denylist, scan, and commit on a clean scan.
159
+
160
+ \b
161
+ Exit codes:
162
+ 0 clean scan (and committed, when --public-clone and --yes are given)
163
+ 1 findings; nothing was committed
164
+ 2 --public-clone without --yes; nothing was committed
165
+
166
+ \b
167
+ Example:
168
+ $ scitex-git mirror export --out /tmp/tree
169
+ $ scitex-git mirror export --out /tmp/tree --public-clone ../pub --tag paper-v0.1 --push --yes
170
+ """
171
+ from .mirror import commit_export, export
172
+
173
+ cfg = _load(project, config)
174
+ result = export(cfg, out=Path(out), ref=ref, leak_check=not no_leak_check)
175
+ wants_commit = bool(public_clone) and not dry_run
176
+ if wants_commit and result.ok and yes:
177
+ result = commit_export(
178
+ cfg, result, Path(out), Path(public_clone), tags=tuple(tags), push=push
179
+ )
180
+ if as_json:
181
+ click.echo(json.dumps({**asdict(result), "ok": result.ok}, indent=2))
182
+ else:
183
+ click.echo(
184
+ f"[mirror] {result.private_sha[:12]} tags={','.join(result.private_tags) or '-'}: "
185
+ f"{result.exported} exported, {result.denied} denied, {len(result.redacted_files)} redacted"
186
+ )
187
+ for f in result.findings:
188
+ click.echo(f"[mirror] FINDING {f}")
189
+ click.echo(f"[mirror] {len(result.findings)} finding(s)")
190
+ if result.public_sha:
191
+ click.echo(
192
+ f"[mirror] committed {result.public_sha[:12]} tags={','.join(result.public_tags) or '-'}"
193
+ f"{' (pushed)' if result.pushed else ''}"
194
+ )
195
+ elif result.findings:
196
+ click.echo("[mirror] REFUSED: nothing was committed")
197
+ elif wants_commit:
198
+ click.echo("[mirror] REFUSED: committing to the public clone needs --yes")
199
+ if not result.ok:
200
+ sys.exit(1)
201
+ sys.exit(2 if wants_commit and not yes else 0)
202
+
203
+
204
+ @mirror_grp.command("validate")
205
+ @click.option(
206
+ "--project", default=".", show_default=True, help="Private repository root."
207
+ )
208
+ @click.option(
209
+ "--config",
210
+ default=None,
211
+ help="Config path (default: <project>/.scitex/git/publish.yaml).",
212
+ )
213
+ @click.option("--ref", default="HEAD", show_default=True, help="Commit to check.")
214
+ def mirror_validate(project, config, ref) -> None:
215
+ """List tracked paths that the publish config denies (exit 1 if any).
216
+
217
+ Useful as a pre-push guard: a denied path that becomes tracked is usually
218
+ an accident. The export drops it either way.
219
+
220
+ \b
221
+ Example:
222
+ $ scitex-git mirror validate --project .
223
+ """
224
+ from .mirror import check_tracked
225
+
226
+ paths = check_tracked(_load(project, config), ref)
227
+ for p in paths:
228
+ click.echo(p)
229
+ if paths:
230
+ click.echo(
231
+ f"[mirror] {len(paths)} tracked path(s) are denied by the publish config; they will "
232
+ "not be exported. Untrack them (git rm --cached) and add them to .gitignore.",
233
+ err=True,
234
+ )
235
+ sys.exit(1 if paths else 0)
236
+
237
+
238
+ @main.command("list-python-apis")
239
+ @click.option("-v", "--verbose", count=True, help="-v names, -vv +signatures, -vvv +docs.")
240
+ @click.option("--json", "as_json", is_flag=True, help="Output as JSON.")
241
+ @click.pass_context
242
+ def list_python_apis(ctx: click.Context, verbose: int, as_json: bool) -> None:
243
+ """List the public Python API of scitex-git.
244
+
245
+ \b
246
+ Example:
247
+ $ scitex-git list-python-apis -vv
248
+ """
249
+ import inspect
250
+
251
+ import scitex_git
252
+
253
+ as_json = as_json or bool((ctx.obj or {}).get("as_json"))
254
+ apis = []
255
+ for name in sorted(getattr(scitex_git, "__all__", [])):
256
+ obj = getattr(scitex_git, name, None)
257
+ if obj is None:
258
+ continue
259
+ entry = {"name": name, "type": type(obj).__name__}
260
+ if callable(obj):
261
+ try:
262
+ entry["signature"] = str(inspect.signature(obj))
263
+ except (TypeError, ValueError):
264
+ pass
265
+ doc = (inspect.getdoc(obj) or "").strip()
266
+ if doc:
267
+ entry["doc"] = doc.split("\n")[0]
268
+ apis.append(entry)
269
+ if as_json:
270
+ click.echo(json.dumps({"module": "scitex_git", "apis": apis}, indent=2))
271
+ return
272
+ for api in apis:
273
+ sig = api.get("signature", "") if verbose >= 2 else ""
274
+ click.echo(f"{api['name']}{sig}")
275
+ if verbose >= 3 and api.get("doc"):
276
+ click.echo(f" {api['doc']}")
277
+
278
+
279
+ @main.group("mcp", invoke_without_command=True)
280
+ @click.pass_context
281
+ def mcp(ctx: click.Context) -> None:
282
+ """MCP (Model Context Protocol) commands. scitex-git ships no MCP server.
283
+
284
+ \b
285
+ Example:
286
+ $ scitex-git mcp list-tools
287
+ """
288
+ if ctx.invoked_subcommand is None:
289
+ click.echo(ctx.get_help())
290
+
291
+
292
+ @mcp.command("list-tools")
293
+ @click.option("--json", "as_json", is_flag=True, help="Output as JSON.")
294
+ @click.pass_context
295
+ def mcp_list_tools(ctx: click.Context, as_json: bool) -> None:
296
+ """List MCP tools exposed by scitex-git (currently none).
297
+
298
+ \b
299
+ Example:
300
+ $ scitex-git mcp list-tools --json
301
+ """
302
+ if as_json or bool((ctx.obj or {}).get("as_json")):
303
+ click.echo(json.dumps({"total": 0, "tools": []}, indent=2))
304
+ return
305
+ click.echo("scitex-git MCP: 0 tools (no MCP server)")
306
+
307
+
308
+ # Ecosystem surfaces provided by scitex-dev when it is installed (audit §1a):
309
+ # `skills {list,get,install}` and `install-/print-shell-completion`.
310
+ try:
311
+ from scitex_dev.cli import attach_shell_completion, skills_click_group
312
+
313
+ main.add_command(skills_click_group(package="scitex-git"), name="skills")
314
+ attach_shell_completion(main, prog_name="scitex-git")
315
+ except ImportError: # pragma: no cover - scitex-dev is an optional extra
316
+ pass
317
+
318
+
319
+ # audit §4: the root --help opens with "<cli> (vX.Y.Z) — <description>".
320
+ main.help = f"scitex-git (v{_version()}) — " + (main.help or "").lstrip()
321
+
322
+
323
+ if __name__ == "__main__":
324
+ main()
@@ -8,12 +8,12 @@ Git clone operations.
8
8
 
9
9
  from pathlib import Path
10
10
 
11
- from logging import getLogger
12
- from ._vendor_sh import sh
11
+ import scitex_logging as slogging
13
12
 
14
13
  from ._constants import EXIT_FAILURE, EXIT_SUCCESS
14
+ from ._vendor_sh import sh
15
15
 
16
- logger = getLogger(__name__)
16
+ logger = slogging.getLogger(__name__)
17
17
 
18
18
 
19
19
  def clone_repo(
@@ -17,14 +17,14 @@ Examples
17
17
 
18
18
  from pathlib import Path
19
19
 
20
- from logging import getLogger
21
- from ._vendor_sh import sh
20
+ import scitex_logging as slogging
22
21
 
23
22
  from ._constants import EXIT_FAILURE, EXIT_SUCCESS
24
23
  from ._utils import _in_directory
25
24
  from ._validation import validate_commit_message, validate_path
25
+ from ._vendor_sh import sh
26
26
 
27
- logger = getLogger(__name__)
27
+ logger = slogging.getLogger(__name__)
28
28
 
29
29
 
30
30
  def git_add_all(repo_path: Path, verbose: bool = True) -> bool:
@@ -37,9 +37,10 @@ import hashlib
37
37
  import json
38
38
  import subprocess
39
39
  from datetime import datetime, timezone
40
- from logging import getLogger
41
40
 
42
- logger = getLogger(__name__)
41
+ import scitex_logging as slogging
42
+
43
+ logger = slogging.getLogger(__name__)
43
44
 
44
45
  __all__ = [
45
46
  "GhSecretError",
@@ -9,13 +9,13 @@ Provides functions to initialize, find, and manage git repositories
9
9
  with different strategies (child, parent, origin).
10
10
  """
11
11
 
12
- from logging import getLogger
13
12
  from pathlib import Path
14
13
  from typing import Optional
15
14
 
15
+ import scitex_logging as slogging
16
16
  from git import InvalidGitRepositoryError, Repo
17
17
 
18
- logger = getLogger(__name__)
18
+ logger = slogging.getLogger(__name__)
19
19
 
20
20
 
21
21
  def find_parent_git(project_dir: Path) -> Optional[Path]:
@@ -8,13 +8,14 @@ Git remote operations.
8
8
  from pathlib import Path
9
9
  from typing import Optional
10
10
 
11
- from logging import getLogger
12
- from ._vendor_sh import sh
11
+ import scitex_logging as slogging
13
12
 
14
13
  from ._constants import EXIT_FAILURE, EXIT_SUCCESS
15
14
  from ._utils import _in_directory
15
+ from ._vendor_sh import sh
16
16
 
17
- logger = getLogger(__name__)
17
+ logger = slogging.getLogger(__name__)
18
+ _out = slogging.getPlainConsole(__name__)
18
19
 
19
20
 
20
21
  def get_remote_url(
@@ -236,7 +237,7 @@ def main(args):
236
237
  if args.action == "get-url":
237
238
  url = get_remote_url(args.repo_path, args.remote_name, args.verbose)
238
239
  if url:
239
- print(url)
240
+ _out.emit(url)
240
241
  return EXIT_SUCCESS
241
242
  return EXIT_FAILURE
242
243
  elif args.action == "check-origin":
@@ -244,7 +245,7 @@ def main(args):
244
245
  logger.error("Expected URL required for check-origin action")
245
246
  return EXIT_FAILURE
246
247
  result = is_cloned_from(args.repo_path, args.expected_url, args.remote_name)
247
- print(result)
248
+ _out.emit(str(result))
248
249
  return EXIT_SUCCESS if result else EXIT_FAILURE
249
250
 
250
251
 
@@ -22,9 +22,9 @@ import subprocess
22
22
  import time
23
23
  from typing import Callable, TypeVar
24
24
 
25
- from logging import getLogger
25
+ import scitex_logging as slogging
26
26
 
27
- logger = getLogger(__name__)
27
+ logger = slogging.getLogger(__name__)
28
28
 
29
29
  T = TypeVar("T")
30
30
 
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: |
3
+ [TOPIC] CLI reference
4
+ [DETAILS] The `scitex-git` command (also `python -m scitex_git`): `mirror export`, `mirror validate`, `list-python-apis`, `mcp list-tools`; flags and exit codes.
5
+ tags: [scitex-git-cli-reference]
6
+ ---
7
+
8
+ # CLI reference
9
+
10
+ ```bash
11
+ scitex-git -V | --version | --help-recursive | --json
12
+ scitex-git list-python-apis [-v...] [--json]
13
+ scitex-git mcp list-tools [--json]
14
+ scitex-git mirror validate [--project DIR] [--config PATH] [--ref REF]
15
+ scitex-git mirror export --out DIR [--project DIR] [--config PATH] [--ref REF]
16
+ [--public-clone PATH] [--tag TAG ...] [--push] [--no-leak-check]
17
+ [--dry-run] [--yes] [--json]
18
+ ```
19
+
20
+ | Command | Does | Exit codes |
21
+ |---|---|---|
22
+ | `mirror validate` | Lists tracked paths that `.scitex/git/publish.yaml` denies | 0 none, 1 some |
23
+ | `mirror export` | Builds the public tree from tracked files, scans it, and commits it to `--public-clone` on a clean scan | 0 clean, 1 findings, 2 `--public-clone` without `--yes` |
24
+
25
+ `--dry-run` builds and scans only. Committing needs `--yes`; `--push` also
26
+ pushes the commit and its tags. See [05_public-mirror.md](05_public-mirror.md)
27
+ for the config and the scans.
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: |
3
+ [TOPIC] Public mirror
4
+ [DETAILS] `scitex-git mirror export` and `.scitex/git/publish.yaml` — keep a repository private and publish a one-way public mirror with fresh history; scans refuse on any finding.
5
+ tags: [scitex-git-public-mirror]
6
+ ---
7
+
8
+ # Public mirror (`scitex-git mirror`)
9
+
10
+ GitHub visibility is per repository, not per branch. When part of a project
11
+ must stay private (held-out data, internal infrastructure notes, third-party
12
+ files that may not be redistributed), keep the repository private and publish
13
+ a separate public repository, exported one way. Nothing flows back.
14
+
15
+ ## Config: `.scitex/git/publish.yaml`
16
+
17
+ ```yaml
18
+ public_repo: owner/name-public
19
+ ref: origin/develop
20
+ tags: ["paper-v*", "abstract-*"] # private tags re-created on the public commit
21
+ include: [] # path regexes; empty = all tracked files
22
+ exclude: ['^data/raw/', '^externals/'] # path regexes never exported
23
+ exclude_from: [config/heldout_paths.txt]
24
+ overlay: {README.md: docs/public_README.md}
25
+ redact: # names code must keep, replaced in the export
26
+ - {pattern: 'db-host-01', replace: 'db-host'}
27
+ license: {code: AGPL-3.0, text: CC-BY-4.0} # a LICENSE file must be exported
28
+ scan:
29
+ secrets: auto # gitleaks, else detect-secrets; neither => refuse
30
+ gitleaks_config: config/gitleaks.toml
31
+ internal_patterns: ['\bdb-host-\d+\b']
32
+ allow: ['10\.0\.2\.15']
33
+ email_allow_domains: [uni.edu]
34
+ leak_check: make check-leaks # optional, run inside the export
35
+ ```
36
+
37
+ ## Commands
38
+
39
+ ```bash
40
+ scitex-git mirror validate # tracked paths the config denies (exit 1 if any)
41
+ scitex-git mirror export --out /tmp/tree # build + scan only
42
+ scitex-git mirror export --out /tmp/tree \
43
+ --public-clone ../name-public --tag paper-v0.1 --push
44
+ ```
45
+
46
+ `export` takes exactly the files tracked at `ref` (never the working tree),
47
+ drops denied paths, applies overlays and redactions, then scans: denied paths,
48
+ LICENSE presence, secrets, private IPv4 ranges, declared internal names,
49
+ e-mail addresses outside the allowlist, and the leak check. Any finding exits
50
+ 1 and nothing is committed. Findings print as `path:line rule`, never the
51
+ value. On a clean scan the public clone gets one new commit whose message
52
+ cites the private SHA and tags and lists the redacted files, plus the
53
+ carried tags. A tag that already exists in the public clone is refused:
54
+ tags are never moved.
55
+
56
+ Python: `from scitex_git.mirror import load_config, export, commit_export, check_tracked`
57
+ (also `stx.git.mirror`).
58
+
59
+ ## Practice
60
+
61
+ - Put every denied path in `.gitignore` too, so it never becomes tracked;
62
+ run `scitex-git mirror validate` before pushing (e.g. from a pre-push hook).
63
+ - Create the public repository empty; the first export is its root commit.
64
+ - Redaction changes file content, so hashes of redacted files differ from the
65
+ private commit. The export commit lists them.
@@ -2,19 +2,19 @@
2
2
  name: scitex-git
3
3
  description: |
4
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.
5
+ [WHEN] Automating git workflows from Python without shelling out and parsing stdout — repo init, commits, branch setup, parent-git discovery; publishing a private repository as a one-way public mirror (`scitex-git mirror export`).
6
6
  [HOW] `from scitex_git import clone_repo, git_init, git_commit, git_add_all, git_retry, ...` — wraps subprocess `git`.
7
7
  tags: [scitex-git]
8
8
  primary_interface: python
9
9
  interfaces:
10
10
  python: 3
11
- cli: 0
11
+ cli: 2
12
12
  mcp: 0
13
13
  skills: 2
14
14
  http: 0
15
15
  ---
16
16
 
17
- > **Interfaces:** Python ⭐⭐⭐ · CLI — · MCP — · Skills ⭐⭐ · Hook — · HTTP —
17
+ > **Interfaces:** Python ⭐⭐⭐ · CLI ⭐⭐ · MCP — · Skills ⭐⭐ · Hook — · HTTP —
18
18
 
19
19
  # scitex-git
20
20
 
@@ -25,6 +25,8 @@ Programmatic git operations — `clone_repo`, `git_init`, `git_commit`, `git_add
25
25
  - [01_installation.md](01_installation.md) — pip install + system `git` requirement
26
26
  - [02_quick-start.md](02_quick-start.md) — clone, init, commit, branch, retry
27
27
  - [03_python-api.md](03_python-api.md) — full public surface
28
+ - [04_cli-reference.md](04_cli-reference.md) — `scitex-git` command, flags, exit codes
29
+ - [05_public-mirror.md](05_public-mirror.md) — `scitex-git mirror export`: one-way public mirror of a private repo (`.scitex/git/publish.yaml`)
28
30
 
29
31
  See README.md and the package's public `__init__.py` for the full
30
32
  function list.