aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-06 14:40:33 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-06 14:40:33 +1300
commit786702e3f1fc9aee755b539cfa633fdc061866bf (patch)
treec6cfa372d8c9c0c55cc69100140fb8ec63aaed9e
parentRefactor Makefile for more generality (diff)
downloadwatch-vcs-tags-786702e3f1fc9aee755b539cfa633fdc061866bf.tar.gz
watch-vcs-tags-786702e3f1fc9aee755b539cfa633fdc061866bf.zip
Refactor tag generation functions
-rw-r--r--watch-git-tags.sh26
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