From 5ea7feee7e2bfc3206ca4d42011e7a364e7ef3ff Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Tue, 23 Oct 2018 03:46:01 +0530 Subject: [PATCH] upgrade-zulip-from-git: Support specifying tag or commit ID for refname. Fixes #10706. Issue: Before this commit, the `refname` positional argument to `upgrade-zulip-from-git` script would run successfully for a branch name on the given remote, but the script would fail if it was provided with a tag or commit ID. Solution: 'git clone -q -b refname LOCAL_GIT_CACHE_DIR deploy_path` would be split into two commands: 1.) `git clone -q LOCAL_GIT_CACHE_DIR deploy_path` 2.) `git checkout -b deploy_timestamp refname` which makes a new branch with the same name as the timestamp used in make_deploy_path. --- scripts/upgrade-zulip-from-git | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade-zulip-from-git b/scripts/upgrade-zulip-from-git index 5ac5c2ad1b..ebc8f92249 100755 --- a/scripts/upgrade-zulip-from-git +++ b/scripts/upgrade-zulip-from-git @@ -55,6 +55,7 @@ get_deployment_lock(error_rerun_script) try: deploy_path = make_deploy_path() + deploy_branch = 'deploy-' + os.path.basename(deploy_path) if not os.path.exists(LOCAL_GIT_CACHE_DIR): logging.info("Cloning the repository") subprocess.check_call(["git", "clone", "-q", remote_url, "--mirror", LOCAL_GIT_CACHE_DIR], @@ -66,10 +67,11 @@ try: subprocess.check_call(["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip) subprocess.check_call(["git", "fetch", "-q"], preexec_fn=su_to_zulip) - subprocess.check_call(["git", "clone", "-q", "-b", refname, LOCAL_GIT_CACHE_DIR, deploy_path], + subprocess.check_call(["git", "clone", "-q", LOCAL_GIT_CACHE_DIR, deploy_path], stdout=open('/dev/null', 'w'), preexec_fn=su_to_zulip) os.chdir(deploy_path) + subprocess.check_call(["git", "checkout", "-b", deploy_branch, refname], preexec_fn=su_to_zulip) subprocess.check_call(["ln", "-nsf", "/etc/zulip/settings.py", os.path.join(deploy_path, "zproject/prod_settings.py")])