Revert "upgrade-zulip-from-git: Provide better error message on a bad refname."

This reverts commit c903128eb7.
This commit is contained in:
Tim Abbott
2025-10-10 16:14:17 -07:00
parent ac636f3c48
commit 83a93fb928

View File

@@ -148,34 +148,28 @@ try:
) )
# Generate the deployment directory via git worktree from our local repository. # Generate the deployment directory via git worktree from our local repository.
try_refs = [ try:
f"refs/tags/{refname}", fullref = f"refs/tags/{refname}"
f"refs/heads/{refname}" if args.local_ref else f"refs/remotes/origin/{refname}", commit_hash = subprocess.check_output(
] ["git", "rev-parse", "--verify", fullref],
commit_hash: str | None = None
fullref: str | None = None
for ref in try_refs:
result = subprocess.run(
["git", "rev-parse", "--verify", ref],
preexec_fn=su_to_zulip, preexec_fn=su_to_zulip,
text=True, text=True,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
check=False, ).strip()
) except subprocess.CalledProcessError as e:
if result.returncode == 0: if e.returncode == 128:
fullref = ref # Try in the origin namespace, or local heads if --local-ref
commit_hash = result.stdout.strip() if args.local_ref:
break fullref = f"refs/heads/{refname}"
elif result.returncode != 128: else:
result.check_returncode() fullref = f"refs/remotes/origin/{refname}"
if not commit_hash or not fullref: commit_hash = subprocess.check_output(
logging.error( ["git", "rev-parse", "--verify", fullref],
"Failed to resolve %s as a tag or %s branch name!", preexec_fn=su_to_zulip,
refname, text=True,
"local" if args.local_ref else "remote", stderr=subprocess.DEVNULL,
) ).strip()
sys.exit(1) refname = fullref
subprocess.check_call( subprocess.check_call(
["git", "worktree", "add", "--detach", deploy_path, refname], ["git", "worktree", "add", "--detach", deploy_path, refname],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,