Fix Git branch support.
This commit is contained in:
parent
17e625474a
commit
6e3203108a
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from .base import Provider
|
||||
from ..addons import Addon
|
||||
|
@ -14,7 +15,7 @@ class Git(Provider):
|
|||
logger.debug("Performing 'git ls-remote' on %s", url)
|
||||
try:
|
||||
subprocess.run(
|
||||
["git", "ls-remote", "-h", "--exit-code", url],
|
||||
["git", "ls-remote", "-h", "--exit-code", *cls.split_branch_url(url)],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
timeout=3,
|
||||
|
@ -31,12 +32,16 @@ class Git(Provider):
|
|||
cls._clone(addon)
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def split_branch_url(cls, url: str) -> List[str]:
|
||||
return url.replace("#", " -b ").split() # allows for '<repo>#<branch>' syntax
|
||||
|
||||
@classmethod
|
||||
def _clone(cls, addon: Addon) -> None:
|
||||
logger.debug("Git clone %s", addon.url)
|
||||
subprocess.call(
|
||||
["git", "clone",
|
||||
*addon.url.replace("#", " -b ").split(), # allows for '<repo>#<branch>' syntax
|
||||
*cls.split_branch_url(addon.url),
|
||||
"--depth", "1",
|
||||
"--single-branch",
|
||||
"--quiet"],
|
||||
|
|
Loading…
Reference in a new issue