fix `is_dirty` when fetching branch with `updated` (#36187)

fix is_dirty
pull/36139/merge
Maxime Desroches 2 days ago committed by GitHub
parent 61d5a50534
commit 073503a6f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      system/updated/updated.py
  2. 7
      system/version.py

@ -382,6 +382,8 @@ class Updater:
setup_git_options(OVERLAY_MERGED) setup_git_options(OVERLAY_MERGED)
run(["git", "config", "--replace-all", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"], OVERLAY_MERGED)
branch = self.target_branch branch = self.target_branch
git_fetch_output = run(["git", "fetch", "origin", branch], OVERLAY_MERGED) git_fetch_output = run(["git", "fetch", "origin", branch], OVERLAY_MERGED)
cloudlog.info("git fetch success: %s", git_fetch_output) cloudlog.info("git fetch success: %s", git_fetch_output)
@ -389,6 +391,7 @@ class Updater:
cloudlog.info("git reset in progress") cloudlog.info("git reset in progress")
cmds = [ cmds = [
["git", "checkout", "--force", "--no-recurse-submodules", "-B", branch, "FETCH_HEAD"], ["git", "checkout", "--force", "--no-recurse-submodules", "-B", branch, "FETCH_HEAD"],
["git", "branch", "--set-upstream-to", f"origin/{branch}"],
["git", "reset", "--hard"], ["git", "reset", "--hard"],
["git", "clean", "-xdff"], ["git", "clean", "-xdff"],
["git", "submodule", "sync"], ["git", "submodule", "sync"],

@ -37,9 +37,7 @@ def is_prebuilt(path: str = BASEDIR) -> bool:
@cache @cache
def is_dirty(cwd: str = BASEDIR) -> bool: def is_dirty(cwd: str = BASEDIR) -> bool:
origin = get_origin() if not get_origin() or not get_short_branch():
branch = get_branch()
if not origin or not branch:
return True return True
dirty = False dirty = False
@ -52,6 +50,9 @@ def is_dirty(cwd: str = BASEDIR) -> bool:
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass pass
branch = get_branch()
if not branch:
return True
dirty = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"], cwd=cwd)) != 0 dirty = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"], cwd=cwd)) != 0
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
cloudlog.exception("git subprocess failed while checking dirty") cloudlog.exception("git subprocess failed while checking dirty")

Loading…
Cancel
Save