diff options
Diffstat (limited to 'watch-git-tags.sh')
-rw-r--r-- | watch-git-tags.sh | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/watch-git-tags.sh b/watch-git-tags.sh index b9fdce8..857fbd0 100644 --- a/watch-git-tags.sh +++ b/watch-git-tags.sh @@ -1,18 +1,10 @@ -#!/bin/sh - -# List sorted local tags -tags_local() { - for repo ; do - git -C "$repo" tag --list | LC_COLLATE=C sort - done -} - -# List sorted remote tags -tags_remote() { - for repo ; do - git -C "$repo" ls-remote --quiet --refs --tags || - printf >&2 'Failed to retrieve tags for repository %s\n' "$PWD" - done | +# Function to retrieve and filter tag names +tags() { + case $1 in + remote) git -C "$repo" show-ref --tags ;; + local) git -C "$repo" ls-remote --quiet --refs --tags ;; + *) return 2 ;; + esac | while read -r _ tag ; do tag=${tag#refs/tags/} printf '%s\n' "$tag" @@ -48,8 +40,8 @@ for repo ; do ( printf '%s\n' "$repo" > path || exit # Write local and remote tags to files - tags_local "$repo" > tags/local || exit - tags_remote "$repo" > tags/remote || exit + tags local "$repo" > tags/local || exit + tags remote "$repo" > tags/remote || exit # Write new tags to file LC_COLLATE=C comm -13 -- tags/local tags/remote > tags/new |