Skip to content

Commit

Permalink
git_deploy: detached head verification fix
Browse files Browse the repository at this point in the history
Signed-off-by:  Eric Callahan <[email protected]>
  • Loading branch information
Arksine committed Aug 14, 2023
1 parent fe12095 commit 3d9052d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions moonraker/components/update_manager/git_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ async def refresh_repo_state(self, need_fetch: bool = True) -> None:

# 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}")
self.upstream_url = await self.remote(f"get-url {self.git_remote}", True)
if await self._check_moved_origin():
need_fetch = True
if self.git_remote == "origin":
self.recovery_url = self.upstream_url
else:
remote_list = (await self.remote("")).splitlines()
remote_list = (await self.remote()).splitlines()
logging.debug(
f"Git Repo {self.alias}: Detected Remotes - {remote_list}"
)
Expand Down Expand Up @@ -513,7 +513,7 @@ async def _find_current_branch(self) -> None:
if current_branch.startswith("(HEAD detached"):
self.head_detached = True
ref_name = current_branch.split()[-1][:-1]
remote_list = (await self.remote("")).splitlines()
remote_list = (await self.remote()).splitlines()
for remote in remote_list:
remote = remote.strip()
if not remote:
Expand Down Expand Up @@ -568,7 +568,8 @@ async def _check_moved_origin(self) -> bool:
f"from {self.upstream_url} to {self.origin_url}")
moved = True
await self.remote(
f"set-url {self.git_remote} {self.origin_url}")
f"set-url {self.git_remote} {self.origin_url}", True
)
self.upstream_url = self.origin_url
if self.moved_origin_url is not None:
moved_origin = self.moved_origin_url.lower().strip()
Expand Down Expand Up @@ -821,8 +822,8 @@ async def list_branches(self) -> List[str]:
resp = await self._run_git_cmd("branch --list --no-color")
return resp.strip().split("\n")

async def remote(self, command: str) -> str:
self._verify_repo(check_remote=True)
async def remote(self, command: str = "", validate: bool = False) -> str:
self._verify_repo(check_remote=validate)
async with self.git_operation_lock:
resp = await self._run_git_cmd(
f"remote {command}")
Expand Down

0 comments on commit 3d9052d

Please sign in to comment.