#!/usr/bin/env bash # Does the release tag `version-` already exist (locally or on origin)? jj only, no git command. # Usage: tag-exists.sh # Exit: 0 = the tag exists, 1 = it does not, 2 = not checked (no jj repository, origin unreachable). # jj has no equivalent of `ls-remote`: the tag alone is fetched (`jj git fetch --tag`), which imports it as a # tracked remote tag if it exists on origin and changes nothing else, then `jj tag list` tells. set -uo pipefail version="${1:?usage: tag-exists.sh }" tag="version-$version" jj root >/dev/null 2>&1 || exit 2 jj git fetch --tag "exact:$tag" >/dev/null 2>&1 || exit 2 if [ -n "$(jj tag list "exact:$tag" -T 'name ++ "\n"' 2>/dev/null)" ]; then exit 0 fi exit 1