WIP: make_update: support Github style of remote organization #104479
|
@ -445,10 +445,17 @@ def external_scripts_update(args: argparse.Namespace,
|
||||||
# automatically and fails when the branch is available in multiple remotes.
|
# automatically and fails when the branch is available in multiple remotes.
|
||||||
if make_utils.git_local_branch_exists(args.git_command, submodule_branch):
|
if make_utils.git_local_branch_exists(args.git_command, submodule_branch):
|
||||||
call([args.git_command, "checkout", submodule_branch])
|
call([args.git_command, "checkout", submodule_branch])
|
||||||
elif make_utils.git_remote_exist(args.git_command, "origin"):
|
else:
|
||||||
call([args.git_command, "checkout", "-t", f"origin/{submodule_branch}"])
|
if make_utils.git_remote_branch_exists(args.git_command, "origin", submodule_branch):
|
||||||
elif make_utils.git_remote_exist(args.git_command, "upstream"):
|
call([args.git_command, "checkout", "-t", f"origin/{submodule_branch}"])
|
||||||
call([args.git_command, "checkout", "-t", f"upstream/{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
|
# Don't use extra fetch since all remotes of interest have been already fetched
|
||||||
# some lines above.
|
# some lines above.
|
||||||
skip_msg += work_tree_update(args, use_fetch=False)
|
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:
|
def git_branch_exists(git_command: str, branch: str) -> bool:
|
||||||
return (
|
return (
|
||||||
git_local_branch_exists(git_command, branch) or
|
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
|
git_remote_branch_exists(git_command, "upstream", branch) or
|
||||||
call([git_command, "rev-parse", "--verify", "remotes/origin/" + branch], exit_on_error=False, silent=True) == 0
|
git_remote_branch_exists(git_command, "origin", branch)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue