update_manager: only fetch the git remote when necessary
After a repo has been updated fetching the remote is not needed, as it was just done in the prior update step. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
b0fda218f1
commit
1acb00e2f1
|
@ -347,7 +347,7 @@ class GitUpdater:
|
||||||
await self._check_version()
|
await self._check_version()
|
||||||
self.init_evt.set()
|
self.init_evt.set()
|
||||||
|
|
||||||
async def _check_version(self):
|
async def _check_version(self, need_fetch=True):
|
||||||
self.is_valid = self.detached = False
|
self.is_valid = self.detached = False
|
||||||
self.cur_hash = self.branch = self.remote = "?"
|
self.cur_hash = self.branch = self.remote = "?"
|
||||||
self.version = self.remote_version = "?"
|
self.version = self.remote_version = "?"
|
||||||
|
@ -377,9 +377,10 @@ class GitUpdater:
|
||||||
self.remote = await self.execute_cmd_with_response(
|
self.remote = await self.execute_cmd_with_response(
|
||||||
f"git -C {self.repo_path} config --get"
|
f"git -C {self.repo_path} config --get"
|
||||||
f" branch.{self.branch}.remote")
|
f" branch.{self.branch}.remote")
|
||||||
await self.execute_cmd(
|
if need_fetch:
|
||||||
f"git -C {self.repo_path} fetch {self.remote} --prune -q",
|
await self.execute_cmd(
|
||||||
retries=3)
|
f"git -C {self.repo_path} fetch {self.remote} --prune -q",
|
||||||
|
retries=3)
|
||||||
remote_url = await self.execute_cmd_with_response(
|
remote_url = await self.execute_cmd_with_response(
|
||||||
f"git -C {self.repo_path} remote get-url {self.remote}")
|
f"git -C {self.repo_path} remote get-url {self.remote}")
|
||||||
cur_hash = await self.execute_cmd_with_response(
|
cur_hash = await self.execute_cmd_with_response(
|
||||||
|
@ -469,7 +470,7 @@ class GitUpdater:
|
||||||
elif need_env_rebuild:
|
elif need_env_rebuild:
|
||||||
await self._update_virtualenv(True)
|
await self._update_virtualenv(True)
|
||||||
# Refresh local repo state
|
# Refresh local repo state
|
||||||
await self._check_version()
|
await self._check_version(need_fetch=False)
|
||||||
if self.name == "moonraker":
|
if self.name == "moonraker":
|
||||||
# Launch restart async so the request can return
|
# Launch restart async so the request can return
|
||||||
# before the server restarts
|
# before the server restarts
|
||||||
|
|
Loading…
Reference in New Issue