mirror of https://github.com/zulip/zulip.git
upgrade-zulip-from-git: Provide a flag to use a local branch.
While this could be done previously by calling `upgrade-zulip-from-git --remote-url /srv/zulip.git`, the explicit argument makes this more straightforward, and avoids churning the `refs/remotes/origin/` namespace.
This commit is contained in:
parent
6e18c84048
commit
5123477d55
|
@ -40,9 +40,15 @@ logging.basicConfig(format="%(asctime)s upgrade-zulip-from-git: %(message)s", le
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("refname", help="Git reference, e.g. a branch, tag, or commit ID.")
|
||||
parser.add_argument(
|
||||
git_ref = parser.add_mutually_exclusive_group()
|
||||
git_ref.add_argument(
|
||||
"--remote-url", help="Override the Git remote URL configured in /etc/zulip/zulip.conf."
|
||||
)
|
||||
git_ref.add_argument(
|
||||
"--local-ref",
|
||||
action="store_true",
|
||||
help="Provided branch name has been pushed directly to /srv/zulip.git already",
|
||||
)
|
||||
args, extra_options = parser.parse_known_args()
|
||||
|
||||
refname = args.refname
|
||||
|
@ -75,6 +81,7 @@ try:
|
|||
subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])
|
||||
|
||||
os.chdir(LOCAL_GIT_CACHE_DIR)
|
||||
if not args.local_ref:
|
||||
subprocess.check_call(
|
||||
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
||||
)
|
||||
|
@ -134,8 +141,10 @@ try:
|
|||
preexec_fn=su_to_zulip,
|
||||
)
|
||||
|
||||
if not args.local_ref:
|
||||
subprocess.check_call(
|
||||
[os.path.join(get_deploy_root(), "scripts/lib/update-git-upstream")], preexec_fn=su_to_zulip
|
||||
[os.path.join(get_deploy_root(), "scripts/lib/update-git-upstream")],
|
||||
preexec_fn=su_to_zulip,
|
||||
)
|
||||
|
||||
# Generate the deployment directory via git worktree from our local repository.
|
||||
|
@ -149,7 +158,10 @@ try:
|
|||
).strip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode == 128:
|
||||
# Try in the origin namespace
|
||||
# Try in the origin namespace, or local heads if --local-ref
|
||||
if args.local_ref:
|
||||
fullref = f"refs/heads/{refname}"
|
||||
else:
|
||||
fullref = f"refs/remotes/origin/{refname}"
|
||||
commit_hash = subprocess.check_output(
|
||||
["git", "rev-parse", "--verify", fullref],
|
||||
|
|
Loading…
Reference in New Issue