mirror of https://github.com/zulip/zulip.git
upgrade-zulip-from-git: Fetch tags from upstream repository.
This ensures that the `git describe` queries that we run for caching Zulip's Git version are guaranteed to include recent releases. This change ensures that we have accurate output even if we're pointed at a fork of Zulip that never updates its tags. Additionally, it will make it possible to record the `git merge-base upstream/master` in future commits. Note that because we run this code before unpacking the new version, the pre-upgrade version of this code runs. As a result, we cannot assume that the upstream repository exists.
This commit is contained in:
parent
b829b95108
commit
03420831b0
|
@ -25,9 +25,8 @@ from scripts.lib.zulip_tools import (
|
||||||
|
|
||||||
config_file = get_config_file()
|
config_file = get_config_file()
|
||||||
deploy_options = get_deploy_options(config_file)
|
deploy_options = get_deploy_options(config_file)
|
||||||
remote_url = get_config(
|
upstream_url = "https://github.com/zulip/zulip.git"
|
||||||
config_file, "deployment", "git_repo_url", "https://github.com/zulip/zulip.git"
|
remote_url = get_config(config_file, "deployment", "git_repo_url", upstream_url)
|
||||||
)
|
|
||||||
|
|
||||||
assert_running_as_root(strip_lib_from_paths=True)
|
assert_running_as_root(strip_lib_from_paths=True)
|
||||||
|
|
||||||
|
@ -58,6 +57,8 @@ get_deployment_lock(error_rerun_script)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
deploy_path = make_deploy_path()
|
deploy_path = make_deploy_path()
|
||||||
|
|
||||||
|
# Populate LOCAL_GIT_CACHE_DIR with both the requested remote and zulip/zulip.
|
||||||
if not os.path.exists(LOCAL_GIT_CACHE_DIR):
|
if not os.path.exists(LOCAL_GIT_CACHE_DIR):
|
||||||
logging.info("Cloning the repository")
|
logging.info("Cloning the repository")
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
|
@ -67,13 +68,22 @@ try:
|
||||||
if os.stat(LOCAL_GIT_CACHE_DIR).st_uid == 0:
|
if os.stat(LOCAL_GIT_CACHE_DIR).st_uid == 0:
|
||||||
subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])
|
subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])
|
||||||
|
|
||||||
logging.info("Fetching the latest commits")
|
|
||||||
os.chdir(LOCAL_GIT_CACHE_DIR)
|
os.chdir(LOCAL_GIT_CACHE_DIR)
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
||||||
)
|
)
|
||||||
subprocess.check_call(["git", "fetch", "-q", "--tags"], preexec_fn=su_to_zulip)
|
|
||||||
|
|
||||||
|
# Ensure upstream remote is configured; we need this to make `git describe` accurate.
|
||||||
|
remotes = subprocess.check_output(["git", "remote"], preexec_fn=su_to_zulip).split(b"\n")
|
||||||
|
if b"upstream" not in remotes:
|
||||||
|
subprocess.check_call(
|
||||||
|
["git", "remote", "add", "upstream", remote_url], preexec_fn=su_to_zulip
|
||||||
|
)
|
||||||
|
|
||||||
|
logging.info("Fetching the latest commits")
|
||||||
|
subprocess.check_call(["git", "fetch", "-q", "--tags", "--all"], preexec_fn=su_to_zulip)
|
||||||
|
|
||||||
|
# Generate the deployment directory via git clone from our local repository.
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
["git", "clone", "-q", "-b", refname, LOCAL_GIT_CACHE_DIR, deploy_path],
|
["git", "clone", "-q", "-b", refname, LOCAL_GIT_CACHE_DIR, deploy_path],
|
||||||
stdout=open("/dev/null", "w"),
|
stdout=open("/dev/null", "w"),
|
||||||
|
|
Loading…
Reference in New Issue