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.
This commit is contained in:
Shubham Padia 2018-10-23 03:46:01 +05:30 committed by Tim Abbott
parent 9f8d778d20
commit 5ea7feee7e
1 changed files with 3 additions and 1 deletions

View File

@ -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")])