run_hooks: Pass down, and respect, --from-git argument.

The refactoring in 4e28e1d3ff incorrectly switched a check for
`if args.from_git` into `if NEW_ZULIP_MERGE_BASE`, which is
incorrect -- the merge-base is always defined, it may just match the
version.  This led to errors when installing from tarball, without a
git repo.

Since the run_hooks command was already set up to take a `--from-git`
argument, but was ignoring it, pass down that flag from
upgrade-zulip-stage-3 when necessary, and swap the run_hooks logic
back to basing the version-resolution logic on that flag.
This commit is contained in:
Alex Vandiver
2025-03-04 20:50:44 +00:00
committed by Tim Abbott
parent 5e4f70c11e
commit 47e622f5a5
2 changed files with 6 additions and 3 deletions

View File

@@ -56,7 +56,7 @@ def resolve_version_string(version: str) -> str:
).strip() ).strip()
if NEW_ZULIP_MERGE_BASE: if args.from_git:
# If we have a git repo, we also resolve those `git describe` # If we have a git repo, we also resolve those `git describe`
# values to full commit hashes, as well as provide the # values to full commit hashes, as well as provide the
# merge-base of the old/new commits with mainline. # merge-base of the old/new commits with mainline.

View File

@@ -389,8 +389,11 @@ else:
# shutting down the server; we should strive to minimize the number of # shutting down the server; we should strive to minimize the number of
# steps that happen between here and the "Restarting Zulip" line # steps that happen between here and the "Restarting Zulip" line
# below. # below.
hooks_args = []
if args.from_git:
hooks_args = ["--from-git"]
subprocess.check_call(["./scripts/lib/run_hooks.py", "pre-deploy"]) subprocess.check_call(["./scripts/lib/run_hooks.py", "pre-deploy", *hooks_args])
if rabbitmq_dist_listen: if rabbitmq_dist_listen:
shutdown_server() shutdown_server()
@@ -450,7 +453,7 @@ else:
logging.info("Upgrade complete!") logging.info("Upgrade complete!")
subprocess.check_call(["./scripts/lib/run_hooks.py", "post-deploy"]) subprocess.check_call(["./scripts/lib/run_hooks.py", "post-deploy", *hooks_args])
if not args.skip_client_reloads and not args.only_django: if not args.skip_client_reloads and not args.only_django:
subprocess.check_call(["./scripts/reload-clients"], preexec_fn=su_to_zulip) subprocess.check_call(["./scripts/reload-clients"], preexec_fn=su_to_zulip)