|
1 | 1 | #!/usr/bin/env python3 |
2 | | -"""Install a skill from a GitHub repo. Project copy: SSL-friendly + git fallback for old Git. |
| 2 | +"""Install a skill from a GitHub repo. SSL-friendly + git fallback for old Git. |
3 | 3 |
|
4 | | -Same CLI as bub skill-installer so the agent can run: uv run scripts/install-skill-from-github.py --repo owner/repo --path path/to/skill. |
| 4 | +Same CLI as bub skill-installer; agent runs: uv run scripts/install-skill-from-github.py |
| 5 | +--repo owner/repo --path path/to/skill. |
5 | 6 | """ |
| 7 | + |
6 | 8 | from __future__ import annotations |
7 | 9 |
|
8 | 10 | import argparse |
@@ -63,6 +65,7 @@ def _ssl_context(): |
63 | 65 | ctx = ssl.create_default_context() |
64 | 66 | try: |
65 | 67 | import certifi |
| 68 | + |
66 | 69 | ctx.load_verify_locations(certifi.where()) |
67 | 70 | except ImportError: |
68 | 71 | pass |
@@ -157,10 +160,21 @@ def _validate_skill_name(name: str) -> None: |
157 | 160 | def _git_sparse_checkout(repo_url: str, ref: str, paths: list[str], dest_dir: str) -> str: |
158 | 161 | repo_dir = os.path.join(dest_dir, "repo") |
159 | 162 | try: |
160 | | - _run_git([ |
161 | | - "git", "clone", "--filter=blob:none", "--depth", "1", |
162 | | - "--sparse", "--single-branch", "--branch", ref, repo_url, repo_dir, |
163 | | - ]) |
| 163 | + _run_git( |
| 164 | + [ |
| 165 | + "git", |
| 166 | + "clone", |
| 167 | + "--filter=blob:none", |
| 168 | + "--depth", |
| 169 | + "1", |
| 170 | + "--sparse", |
| 171 | + "--single-branch", |
| 172 | + "--branch", |
| 173 | + ref, |
| 174 | + repo_url, |
| 175 | + repo_dir, |
| 176 | + ] |
| 177 | + ) |
164 | 178 | _run_git(["git", "-C", repo_dir, "sparse-checkout", "set", *paths]) |
165 | 179 | _run_git(["git", "-C", repo_dir, "checkout", ref]) |
166 | 180 | return repo_dir |
@@ -201,7 +215,7 @@ def _prepare_repo(source: Source, method: str, tmp_dir: str) -> str: |
201 | 215 | if method in ("download", "auto"): |
202 | 216 | try: |
203 | 217 | return _download_repo_zip(source.owner, source.repo, source.ref, tmp_dir) |
204 | | - except InstallError as exc: |
| 218 | + except InstallError: |
205 | 219 | if method == "download": |
206 | 220 | raise |
207 | 221 | # auto: fall back to git on any download error (HTTP, SSL, timeout) |
|
0 commit comments