def updateCheck():
from pathlib import Path
if not shutil.which("git"):
return
# check if new commits are available
projectDir = str(Path(__file__).parent)
subprocess.call(["git", "fetch"], cwd=projectDir)
output = subprocess.check_output(["git", "status", "-uno"], cwd=projectDir)
behindIndex = output.find(b"Your branch is behind ")
if behindIndex > 0:
msgEnd = output.find(b"\n (use \"git pull\" to update your local branch)")
if msgEnd > 0:
output = output[behindIndex:msgEnd]
statusUpdate("Current CheriBuild checkout can be updated: ", output.decode("utf-8"))
if input("Would you like to update before continuing? y/[n] (Enter to skip) ").lower().startswith("y"):
subprocess.check_call(["git", "pull", "--rebase"], cwd=projectDir)
os.execv(sys.argv[0], sys.argv)
评论列表
文章目录