Unverified Commit 0a74bfce authored by Russell Bryant's avatar Russell Bryant Committed by GitHub
Browse files

setup.py: drop assumption about local `main` branch (#14692)


Signed-off-by: default avatarRussell Bryant <rbryant@redhat.com>
parent dd3b8658
...@@ -294,26 +294,28 @@ class repackage_wheel(build_ext): ...@@ -294,26 +294,28 @@ class repackage_wheel(build_ext):
]).decode("utf-8") ]).decode("utf-8")
upstream_main_commit = json.loads(resp_json)["sha"] upstream_main_commit = json.loads(resp_json)["sha"]
# Check if the local main branch is up-to-date. This is to ensure # Check if the upstream_main_commit exists in the local repo
# the base commit we found is the most recent commit on the main try:
# branch. subprocess.check_output(
local_main_commit = subprocess.check_output( ["git", "cat-file", "-e", f"{upstream_main_commit}"])
["git", "rev-parse", "main"]).decode("utf-8").strip() except subprocess.CalledProcessError:
if local_main_commit != upstream_main_commit: # If not present, fetch it from the remote repository.
raise ValueError( # Note that this does not update any local branches,
f"Local main branch ({local_main_commit}) is not " # but ensures that this commit ref and its history are
"up-to-date with upstream main branch " # available in our local repo.
f"({upstream_main_commit}). Please pull the latest " subprocess.check_call([
"changes from upstream main branch first.") "git", "fetch", "https://github.com/vllm-project/vllm",
"main"
])
# Then get the commit hash of the current branch that is the same as # Then get the commit hash of the current branch that is the same as
# the upstream main commit. # the upstream main commit.
current_branch = subprocess.check_output( current_branch = subprocess.check_output(
["git", "branch", "--show-current"]).decode("utf-8").strip() ["git", "branch", "--show-current"]).decode("utf-8").strip()
base_commit = subprocess.check_output( base_commit = subprocess.check_output([
["git", "merge-base", "main", "git", "merge-base", f"{upstream_main_commit}", current_branch
current_branch]).decode("utf-8").strip() ]).decode("utf-8").strip()
return base_commit return base_commit
except ValueError as err: except ValueError as err:
raise ValueError(err) from None raise ValueError(err) from None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment