update_manager: add support for moved git repos
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
2447ccab62
commit
9c09ca2ed5
|
@ -76,6 +76,7 @@ class AppDeploy(BaseDeploy):
|
||||||
# all options apply to each subtype, however we can't limit the
|
# all options apply to each subtype, however we can't limit the
|
||||||
# options in children if we want to switch between channels and
|
# options in children if we want to switch between channels and
|
||||||
# satisfy the confighelper's requirements.
|
# satisfy the confighelper's requirements.
|
||||||
|
self.moved_origin: Optional[str] = config.get('moved_origin', None)
|
||||||
self.origin: str = config.get('origin')
|
self.origin: str = config.get('origin')
|
||||||
self.primary_branch = config.get("primary_branch", "master")
|
self.primary_branch = config.get("primary_branch", "master")
|
||||||
self.npm_pkg_json: Optional[pathlib.Path] = None
|
self.npm_pkg_json: Optional[pathlib.Path] = None
|
||||||
|
|
|
@ -37,7 +37,8 @@ class GitDeploy(AppDeploy):
|
||||||
app_params: Optional[Dict[str, Any]] = None
|
app_params: Optional[Dict[str, Any]] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(config, cmd_helper, app_params)
|
super().__init__(config, cmd_helper, app_params)
|
||||||
self.repo = GitRepo(cmd_helper, self.path, self.name, self.origin)
|
self.repo = GitRepo(cmd_helper, self.path, self.name,
|
||||||
|
self.origin, self.moved_origin)
|
||||||
if self.type != 'git_repo':
|
if self.type != 'git_repo':
|
||||||
self.need_channel_update = True
|
self.need_channel_update = True
|
||||||
|
|
||||||
|
@ -203,7 +204,8 @@ class GitRepo:
|
||||||
cmd_helper: CommandHelper,
|
cmd_helper: CommandHelper,
|
||||||
git_path: pathlib.Path,
|
git_path: pathlib.Path,
|
||||||
alias: str,
|
alias: str,
|
||||||
origin_url: str
|
origin_url: str,
|
||||||
|
moved_origin_url: Optional[str]
|
||||||
) -> None:
|
) -> None:
|
||||||
self.server = cmd_helper.get_server()
|
self.server = cmd_helper.get_server()
|
||||||
self.cmd_helper = cmd_helper
|
self.cmd_helper = cmd_helper
|
||||||
|
@ -213,6 +215,7 @@ class GitRepo:
|
||||||
git_base = git_path.name
|
git_base = git_path.name
|
||||||
self.backup_path = git_dir.joinpath(f".{git_base}_repo_backup")
|
self.backup_path = git_dir.joinpath(f".{git_base}_repo_backup")
|
||||||
self.origin_url = origin_url
|
self.origin_url = origin_url
|
||||||
|
self.moved_origin_url = moved_origin_url
|
||||||
self.valid_git_repo: bool = False
|
self.valid_git_repo: bool = False
|
||||||
self.git_owner: str = "?"
|
self.git_owner: str = "?"
|
||||||
self.git_remote: str = "?"
|
self.git_remote: str = "?"
|
||||||
|
@ -261,6 +264,28 @@ class GitRepo:
|
||||||
self.git_remote = await self.get_config_item(
|
self.git_remote = await self.get_config_item(
|
||||||
f"branch.{self.git_branch}.remote")
|
f"branch.{self.git_branch}.remote")
|
||||||
|
|
||||||
|
# Fetch the upstream url. If the repo has been moved,
|
||||||
|
# set the new url
|
||||||
|
self.upstream_url = await self.remote(f"get-url {self.git_remote}")
|
||||||
|
if self.moved_origin_url is not None:
|
||||||
|
origin = self.upstream_url.lower().strip()
|
||||||
|
if not origin.endswith(".git"):
|
||||||
|
origin += ".git"
|
||||||
|
moved_origin = self.moved_origin_url.lower().strip()
|
||||||
|
if not moved_origin.endswith(".git"):
|
||||||
|
moved_origin += ".git"
|
||||||
|
if origin == moved_origin:
|
||||||
|
logging.info(
|
||||||
|
f"Git Repo {self.alias}: Moved Repo Detected, Moving "
|
||||||
|
f"from {self.upstream_url} to {self.origin_url}")
|
||||||
|
need_fetch = True
|
||||||
|
await self.remote(
|
||||||
|
f"set-url {self.git_remote} {self.origin_url}")
|
||||||
|
self.upstream_url = self.origin_url
|
||||||
|
|
||||||
|
if need_fetch:
|
||||||
|
await self.fetch()
|
||||||
|
|
||||||
# Populate list of current branches
|
# Populate list of current branches
|
||||||
blist = await self.list_branches()
|
blist = await self.list_branches()
|
||||||
self.branches = []
|
self.branches = []
|
||||||
|
@ -272,10 +297,6 @@ class GitRepo:
|
||||||
continue
|
continue
|
||||||
self.branches.append(branch)
|
self.branches.append(branch)
|
||||||
|
|
||||||
if need_fetch:
|
|
||||||
await self.fetch()
|
|
||||||
|
|
||||||
self.upstream_url = await self.remote(f"get-url {self.git_remote}")
|
|
||||||
self.current_commit = await self.rev_parse("HEAD")
|
self.current_commit = await self.rev_parse("HEAD")
|
||||||
self.upstream_commit = await self.rev_parse(
|
self.upstream_commit = await self.rev_parse(
|
||||||
f"{self.git_remote}/{self.git_branch}")
|
f"{self.git_remote}/{self.git_branch}")
|
||||||
|
|
|
@ -9,7 +9,8 @@ install_script: scripts/install-moonraker.sh
|
||||||
host_repo: arksine/moonraker
|
host_repo: arksine/moonraker
|
||||||
|
|
||||||
[update_manager klipper]
|
[update_manager klipper]
|
||||||
origin: https://github.com/kevinoconnor/klipper.git
|
moved_origin: https://github.com/kevinoconnor/klipper.git
|
||||||
|
origin: https://github.com/Klipper3d/klipper.git
|
||||||
requirements: scripts/klippy-requirements.txt
|
requirements: scripts/klippy-requirements.txt
|
||||||
venv_args: -p python2
|
venv_args: -p python2
|
||||||
install_script: scripts/install-octopi.sh
|
install_script: scripts/install-octopi.sh
|
||||||
|
|
Loading…
Reference in New Issue