Fix make update for upstream workflow and missing branch in submodule
Fix the issue when upstream workflow is used and the addons fork does not yet have the release branch. In this case create a local branch which is based on the upstream/<branch> but does not track anything. Typically with such workflow the local branches will track origin, but since the origin does not have the branch yet it is not possible to track it. Test plan: - Use upstream workflow - Have a fork of addons, which does not have blender-v3.6-release - Run make update The error message: ``` Updating scripts/addons ... git fetch origin git fetch upstream git checkout -t origin/blender-v3.6-release fatal: 'origin/blender-v3.6-release' is not a commit and a branch 'blender-v3.6-release' cannot be created from it make: *** [update] Error 128 ``` Pull Request: https://projects.blender.org/blender/blender/pulls/108197
This commit is contained in:
parent
a4aee6a997
commit
d1254519ad
@ -445,10 +445,17 @@ def external_scripts_update(args: argparse.Namespace,
|
||||
# automatically and fails when the branch is available in multiple remotes.
|
||||
if make_utils.git_local_branch_exists(args.git_command, submodule_branch):
|
||||
call([args.git_command, "checkout", submodule_branch])
|
||||
elif make_utils.git_remote_exist(args.git_command, "origin"):
|
||||
call([args.git_command, "checkout", "-t", f"origin/{submodule_branch}"])
|
||||
elif make_utils.git_remote_exist(args.git_command, "upstream"):
|
||||
call([args.git_command, "checkout", "-t", f"upstream/{submodule_branch}"])
|
||||
else:
|
||||
if make_utils.git_remote_branch_exists(args.git_command, "origin", submodule_branch):
|
||||
call([args.git_command, "checkout", "-t", f"origin/{submodule_branch}"])
|
||||
elif make_utils.git_remote_exist(args.git_command, "upstream"):
|
||||
# For the Github style of upstream workflow create a local branch from
|
||||
# the upstream, but do not track it, so that we stick to the paradigm
|
||||
# that no local branches are tracking upstream, preventing possible
|
||||
# accidental commit to upstream.
|
||||
call([args.git_command, "checkout", "-b", submodule_branch,
|
||||
f"upstream/{submodule_branch}", "--no-track"])
|
||||
|
||||
# Don't use extra fetch since all remotes of interest have been already fetched
|
||||
# some lines above.
|
||||
skip_msg += work_tree_update(args, use_fetch=False)
|
||||
|
@ -60,11 +60,16 @@ def git_local_branch_exists(git_command: str, branch: str) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def git_remote_branch_exists(git_command: str, remote: str, branch: str) -> bool:
|
||||
return call([git_command, "rev-parse", "--verify", f"remotes/{remote}/{branch}"],
|
||||
exit_on_error=False, silent=True) == 0
|
||||
|
||||
|
||||
def git_branch_exists(git_command: str, branch: str) -> bool:
|
||||
return (
|
||||
git_local_branch_exists(git_command, branch) or
|
||||
call([git_command, "rev-parse", "--verify", "remotes/upstream/" + branch], exit_on_error=False, silent=True) == 0 or
|
||||
call([git_command, "rev-parse", "--verify", "remotes/origin/" + branch], exit_on_error=False, silent=True) == 0
|
||||
git_remote_branch_exists(git_command, "upstream", branch) or
|
||||
git_remote_branch_exists(git_command, "origin", branch)
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user