Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions devchat/_cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import stat
import shutil
import sys
from typing import List, Optional
from typing import List, Optional, Tuple

import rich_click as click
from devchat._cli.utils import init_dir, handle_errors, clone_git_repo
Expand Down Expand Up @@ -55,8 +55,8 @@ def run(command: str, list_flag: bool, recursive_flag: bool, update_sys_flag: bo
if update_sys_flag:
sys_dir = os.path.join(workflows_dir, 'sys')
git_urls = [
'https://gitlab.com/devchat-ai/workflows.git',
'https://github.com/devchat-ai/workflows.git'
('https://gitlab.com/devchat-ai/workflows.git', 'main'),
('https://github.com/devchat-ai/workflows.git', 'main')
]
zip_urls = [
'https://gitlab.com/devchat-ai/workflows/-/archive/main/workflows-main.zip',
Expand Down Expand Up @@ -120,7 +120,7 @@ def __make_files_writable(directory):
if not os.access(filepath, os.W_OK):
os.chmod(filepath, stat.S_IWUSR)

def _clone_or_pull_git_repo(target_dir: str, repo_urls: List[str], zip_urls: List[str]):
def _clone_or_pull_git_repo(target_dir: str, repo_urls: List[Tuple[str, str]], zip_urls: List[str]):
"""
Clone a Git repository to a specified location, or pull it if it already exists.

Expand Down
6 changes: 3 additions & 3 deletions devchat/_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ def valid_git_repo(target_dir: str, valid_urls: List[str]) -> bool:
return False


def clone_git_repo(target_dir: str, repo_urls: List[str]):
def clone_git_repo(target_dir: str, repo_urls: List[Tuple[str, str]]):
"""
Clone a Git repository from a list of possible URLs.

:param target_dir: The path where the repository should be cloned.
:param repo_urls: A list of possible Git repository URLs.
"""
for url in repo_urls:
for url, branch in repo_urls:
try:
click.echo(f"Cloning repository {url} to {target_dir}")
Repo.clone_from(url, target_dir)
Repo.clone_from(url, target_dir, branch=branch)
click.echo("Cloned successfully")
return
except GitCommandError:
Expand Down