Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upgrade-zulip-from-git: Extract code to set zulip upstream remote.

Alex Vandiver96e42b8e811f
diff --git a/scripts/lib/update-git-upstream b/scripts/lib/update-git-upstream
new file mode 100755
index 00000000000..1cf17f933ba
--- /dev/null
+++ b/scripts/lib/update-git-upstream
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -eu
+
+upstream_url="https://github.com/zulip/zulip.git"
+if ! git remote | grep -qx upstream; then
+ git remote add upstream "$upstream_url"
+else
+ git remote set-url upstream "$upstream_url"
+fi
+
+git fetch --prune --quiet --tags --all
diff --git a/scripts/lib/upgrade-zulip-from-git b/scripts/lib/upgrade-zulip-from-git
index 335e2788433..48bd8527a48 100755
--- a/scripts/lib/upgrade-zulip-from-git
+++ b/scripts/lib/upgrade-zulip-from-git
@@ -25,8 +25,9 @@ from scripts.lib.zulip_tools import (
config_file = get_config_file()
deploy_options = get_deploy_options(config_file)
-upstream_url = "https://github.com/zulip/zulip.git"
-remote_url = get_config(config_file, "deployment", "git_repo_url", upstream_url)
+remote_url = get_config(
+ config_file, "deployment", "git_repo_url", "https://github.com/zulip/zulip.git"
+)
assert_running_as_root(strip_lib_from_paths=True)
@@ -132,21 +133,7 @@ try:
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", upstream_url], preexec_fn=su_to_zulip
- )
- else:
- subprocess.check_call(
- ["git", "remote", "set-url", "upstream", upstream_url], preexec_fn=su_to_zulip
- )
-
- logging.info("Fetching the latest commits")
- subprocess.check_call(
- ["git", "fetch", "--prune", "--quiet", "--tags", "--all"], preexec_fn=su_to_zulip
- )
+ subprocess.check_call(["./scripts/lib/update-git-upstream"], preexec_fn=su_to_zulip)
# Generate the deployment directory via git worktree from our local repository.
try: