diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-11-30 14:45:03 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-11-30 14:45:03 +1300 |
commit | 98df311a42ef06ddf0559b62696b82bf800a5b34 (patch) | |
tree | 7b3f126773200deeb9c33a81d9a4e4af02761823 | |
parent | Merge branch 'release/v3.0.0' (diff) | |
parent | Bump VERSION (diff) | |
download | watch-vcs-tags-3.1.0.tar.gz (sig) watch-vcs-tags-3.1.0.zip |
Merge branch 'release/v3.1.0'v3.1.0
* release/v3.1.0:
Correct a comment
Use short-circuit logic for pre-fetch test
Rename and refactor local functions
-rw-r--r-- | VERSION | 2 | ||||
-rwxr-xr-x | watch-git-tags | 35 |
2 files changed, 19 insertions, 18 deletions
@@ -1 +1 @@ -3.0.0 +3.1.0 diff --git a/watch-git-tags b/watch-git-tags index af60664..e7d2c59 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,25 +49,20 @@ 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 # Attempt to quietly fetch new tags so that we don't notify about the same # ones next time - if [ -s new ] ; then - git fetch --quiet --tags - fi + [ -s new ] || continue + git -C "$repo" fetch --quiet --tags ) & done -# Wait for each of those to finish +# Wait for all of those to finish wait # Iterate through the temp dirs in order |