Skip to content

Commit 0305500

Browse files
committed
Don't check for existing branch on remote at clone time
1 parent 4fe836a commit 0305500

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

cookie_python/manage/repo.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import sys
88
import tempfile
9-
from functools import cached_property, partial
9+
from functools import cached_property
1010
from pathlib import Path
1111
from types import TracebackType
1212
from typing import Any, Optional
@@ -50,18 +50,11 @@ def clone_path(self) -> Path:
5050
["git", "clone", self.repo, "repo"], cwd=self.tempdir, check=True
5151
)
5252
clone_path = self.tempdir / "repo"
53-
run = partial(subprocess.run, cwd=clone_path, check=True)
54-
if (
55-
run(
56-
["git", "ls-remote", "origin", self.branch],
57-
capture_output=True,
58-
)
59-
.stdout.decode() # type: ignore
60-
.strip()
53+
for cmd in (
54+
["git", "checkout", "-b", self.branch],
55+
["git", "reset", "--hard", "origin/main"],
6156
):
62-
raise Exception(f'Branch "{self.branch}" already exists on remote')
63-
run(["git", "checkout", "-b", self.branch])
64-
run(["git", "reset", "--hard", "origin/main"])
57+
subprocess.run(cmd, cwd=clone_path, check=True)
6558
return clone_path
6659

6760
def cruft_attr(self, attr: str) -> str:

0 commit comments

Comments
 (0)