Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions github_scripts/get_git_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ def get_unmerged(loc: Path) -> list[str]:
return files.stdout.split()


def check_existing(loc: Path) -> None:
def check_existing(loc: Path) -> bool:
"""
If the repository exists and isn't a git repo, exit now as we don't want to
overwrite it
Return whether the repository already exists. If it does but isn't a git
repo, exit now as we don't want to overwrite it.
"""

if loc.exists():
Expand All @@ -292,6 +292,8 @@ def check_existing(loc: Path) -> None:
f"The destination, '{loc}', already exists but isn't a git directory. "
"Exiting so as to not overwrite it."
)
return True
return False


def clone_repo_mirror(
Expand Down Expand Up @@ -361,7 +363,7 @@ def clone_repo(repo_source: str, repo_ref: str, loc: Path) -> None:
- loc: path to clone the repository to
"""

if not loc.exists():
if not check_existing(loc):
# Create a clean clone location
loc.mkdir(parents=True)

Expand All @@ -377,7 +379,6 @@ def clone_repo(repo_source: str, repo_ref: str, loc: Path) -> None:
for command in commands:
run_command(command)
else:
check_existing(loc)
commands = (
f"git -C {loc} fetch origin {repo_ref}",
f"git -C {loc} checkout FETCH_HEAD",
Expand Down
Loading