Skip to content
Snippets Groups Projects
Commit 120e88bb authored by Filippo Cremonese's avatar Filippo Cremonese
Browse files

Get remote list dynamically

parent 5a007e96
No related branches found
No related tags found
No related merge requests found
import os.path
import re
from functools import cached_property
from .action import Action
from .util import run_script
......@@ -30,13 +31,17 @@ class CloneAction(Action):
def _is_satisfied(self):
return os.path.exists(self.environment["SOURCE_DIR"])
@cached_property
def remotes(self):
result = run_script('git -C "$ORCHESTRA_DOTDIR" remote show', environment=self.environment, quiet=True)
return result.stdout.decode("utf-8").split("\n").strip().split("\n")
def remote_base_urls(self):
# TODO: the remote is not necessarily called origin, and there might be more than one
# remote names should be configurable
remotes = ["origin", "private"]
base_urls = []
for remote in remotes:
for remote in self.remotes:
result = run_script(
f'git -C "$ORCHESTRA_DOTDIR" config --get remote.{remote}.url',
environment=self.environment,
......@@ -64,7 +69,7 @@ class CloneAction(Action):
quiet=True,
environment=self.environment,
check_returncode=False
).stdout.decode("utf-8")
).stdout.decode("utf-8")
parse_regex = re.compile(r"(?P<commit>[a-f0-9]*)\W*refs/heads/(?P<branch>.*)")
matches = parse_regex.findall(result)
for commit, branch in matches:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment