fix `is_dirty` when switching branch with `updated` (#36162)

* clean

* fix
pull/36167/head
Maxime Desroches 4 weeks ago committed by GitHub
parent b622e3e0a7
commit 30c388aea8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      system/updated/updated.py
  2. 7
      system/version.py

@ -113,6 +113,7 @@ def setup_git_options(cwd: str) -> None:
("protocol.version", "2"),
("gc.auto", "0"),
("gc.autoDetach", "false"),
("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"),
]
for option, value in git_cfg:
run(["git", "config", option, value], cwd)
@ -389,6 +390,7 @@ class Updater:
cloudlog.info("git reset in progress")
cmds = [
["git", "checkout", "--force", "--no-recurse-submodules", "-B", branch, "FETCH_HEAD"],
["git", "branch", "--set-upstream-to", f"origin/{branch}"],
["git", "reset", "--hard"],
["git", "clean", "-xdff"],
["git", "submodule", "sync"],

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

Loading…
Cancel
Save