tj.git-extras/bin/git-delete-tag
spacewander 753555744b git-delete-tag: should not be quoted
Otherwise the whole result will be considered one tag/ref.
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
2023-03-07 09:11:37 +08:00

29 lines
621 B
Bash
Executable file

#!/usr/bin/env bash
# Assert there is at least one tag provided
test -z "$1" && echo "tag required." 1>&2 && exit 1
# Detect the default remote exists or not
default_remote=$(git config git-extras.default-remote)
if [[ -n "$default_remote" ]]; then
origin="$default_remote"
else
origin=origin
fi
# Concatenate all the tag references
local_tags=""
origin_refs=""
for tagname in "$@"
do
local_tags=$local_tags" $tagname"
origin_refs=$origin_refs" :refs/tags/$tagname"
done
# Delete all the tags
# shellcheck disable=SC2086
git tag -d $local_tags
# shellcheck disable=SC2086
git push "$origin" $origin_refs