diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-11-30 17:10:20 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-06 14:33:20 +1300 |
commit | 7fb468b76d0a503897f492a98e9b9f7f238c6a50 (patch) | |
tree | 9fd88dea9e1a14ae7ba204dfa4d09eb95436e9f4 /watch-git-tags | |
parent | Use correct control structure for loop body exit (diff) | |
download | watch-vcs-tags-7fb468b76d0a503897f492a98e9b9f7f238c6a50.tar.gz watch-vcs-tags-7fb468b76d0a503897f492a98e9b9f7f238c6a50.zip |
Add Makefile and manual page
Diffstat (limited to 'watch-git-tags')
-rwxr-xr-x | watch-git-tags | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/watch-git-tags b/watch-git-tags deleted file mode 100755 index b9fdce8..0000000 --- a/watch-git-tags +++ /dev/null @@ -1,84 +0,0 @@ -#!/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 | - 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 -# remove it when the script exits; requires mktemp(1) (not POSIX) -td=$(mktemp -d) || exit -cleanup() { - [ -n "$td" ] || return - rm -fr -- "$td" -} -for sig in EXIT HUP INT TERM ; do - # shellcheck disable=SC2064 - trap "cleanup $sig" "$sig" -done - -# Use current directory if no other arguments -[ "$#" -gt 0 ] || set -- . - -# Iterate through each repo in a subshell in parallel -for repo ; do ( - - # Make a temporary directory with a hash in its name for uniqueness - name=$(printf '%s' "$repo" | sed 's:/:_:g') - cksum=$(printf '%s' "$repo" | cksum | sed 's:[^0-9].*::') - sd=$td/$name.$cksum - mkdir -- "$sd" "$sd"/tags || exit - - # Step in and write repo path to file - cd -- "$sd" || exit - 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 - - # Write new tags to file - LC_COLLATE=C comm -13 -- tags/local tags/remote > tags/new - - # Attempt to quietly fetch new tags so that we don't notify about the same - # ones next time - [ -s tags/new ] || exit - git -C "$repo" fetch --quiet --tags - -) & done - -# Wait for all of those to finish -wait - -# Iterate through the temp dirs in order -for dir in "$td"/* ; do ( - cd -- "$dir" || exit - - # Look for non-zero "new" files (at least one new tag) - [ -s tags/new ] || exit - - # Print repository path and new tags - cat path - while read -r tag ; do - printf '* %s\n' "$tag" - done < tags/new - -) ; done - -# Haven't yet decided on exit value semantics; for the moment, if it completes, -# exit success -exit 0 |