Spaces:
Running on Zero
Running on Zero
fix(spaces): _git_clone uses init+fetch so SHA refs work
Browse filesgit clone --branch only accepts branch/tag names, so cloning ComfyUI by
its pinned SHA failed on Spaces with "Remote branch <sha> not found in
upstream origin". Switching to init + fetch --depth 1 origin <ref> +
checkout FETCH_HEAD, which handles branches, tags, and SHAs uniformly.
app.py
CHANGED
|
@@ -42,9 +42,20 @@ CUSTOM_NODES_PINNED: list[tuple[str, str]] = [
|
|
| 42 |
|
| 43 |
|
| 44 |
def _git_clone(url: str, dst: pathlib.Path, ref: str) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
import subprocess
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
def _bootstrap() -> None:
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
def _git_clone(url: str, dst: pathlib.Path, ref: str) -> None:
|
| 45 |
+
"""Clone *url* at *ref* into *dst*. *ref* may be a branch, tag, or SHA.
|
| 46 |
+
|
| 47 |
+
`git clone --branch` only accepts branch/tag names, so we use init+fetch
|
| 48 |
+
which works for any object GitHub allows fetching (default: reachable
|
| 49 |
+
commits in public repos).
|
| 50 |
+
"""
|
| 51 |
import subprocess
|
| 52 |
|
| 53 |
+
dst = pathlib.Path(dst)
|
| 54 |
+
dst.mkdir(parents=True, exist_ok=True)
|
| 55 |
+
subprocess.check_call(["git", "-C", str(dst), "init", "-q"])
|
| 56 |
+
subprocess.check_call(["git", "-C", str(dst), "remote", "add", "origin", url])
|
| 57 |
+
subprocess.check_call(["git", "-C", str(dst), "fetch", "--depth", "1", "origin", ref])
|
| 58 |
+
subprocess.check_call(["git", "-C", str(dst), "checkout", "-q", "FETCH_HEAD"])
|
| 59 |
|
| 60 |
|
| 61 |
def _bootstrap() -> None:
|