From 992ac9a112411c38fd6b63ac30f06f2047977bcc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Nov 2018 14:43:05 +1300 Subject: Rename and refactor local functions --- watch-git-tags | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/watch-git-tags b/watch-git-tags index af60664..7ff640a 100755 --- a/watch-git-tags +++ b/watch-git-tags @@ -2,16 +2,22 @@ self=watch-git-tags # List sorted local tags -lt() { - git tag --list | - LC_COLLATE=C sort +local_tags() { + for repo ; do + git -C "$repo" tag --list | LC_COLLATE=C sort + done } # List sorted remote tags -rt() { - { git ls-remote --quiet --refs --tags || - printf >&2 'Failed to retrieve tags for repository %s\n' "$PWD" - } | cut -d/ -f3 | LC_COLLATE=C sort +remote_tags() { + for repo ; do + git -C "$repo" ls-remote --quiet --refs --tags || + printf >&2 'Failed to retrieve tags for repository %s\n' "$PWD" + done | + while read -r _ tag ; do + tag=${tag#refs/tags/} + printf '%s\n' "$tag" + done } # Create a temporary directory with name in $td, and handle POSIX-ish traps to @@ -43,12 +49,8 @@ for repo ; do ( printf '%s\n' "$repo" > path || exit # Write local and remote tags to files - ( - cd -- "$repo" || exit - lt > "$sd"/a || exit - rt > "$sd"/b - ) || - exit + local_tags "$repo" > "$sd"/a || exit + remote_tags "$repo" > "$sd"/b || exit # Write new tags to file LC_COLLATE=C comm -13 -- [ab] > new -- cgit v1.2.3