diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-06 14:59:43 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-06 14:59:43 +1300 |
commit | d2ec1aa9748f2e65c7037d0c16d8eea9ebdd16ed (patch) | |
tree | d3960fa2eb2ec35207229931c8dfe5bbb5ff0195 /watch-git-tags | |
parent | Merge branch 'release/v3.1.0' (diff) | |
parent | Bump VERSION (diff) | |
download | watch-vcs-tags-master.tar.gz watch-vcs-tags-master.zip |
* release/v4.0.0:
Correct subcommands for tags generation function
Remove unneeded semicolon
Correct/adjust default behaviour with no args
Refactor tag generation functions
Refactor Makefile for more generality
Add Makefile and manual page
Use correct control structure for loop body exit
Remove unused $self variable
Refactor script some more
Diffstat (limited to 'watch-git-tags')
-rwxr-xr-x | watch-git-tags | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/watch-git-tags b/watch-git-tags deleted file mode 100755 index e7d2c59..0000000 --- a/watch-git-tags +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -self=watch-git-tags - -# List sorted local tags -local_tags() { - for repo ; do - git -C "$repo" tag --list | LC_COLLATE=C sort - done -} - -# List sorted remote tags -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 -# 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 - df=$(printf %s "$repo" | sed s:/:_:g) - cs=$(printf %s "$repo" | cksum) - sd=$td/$df.${cs%% *} - mkdir -- "$sd" || 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 - 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 - [ -s new ] || continue - 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 0 - - # Look for non-zero "new" files (at least one new tag) - [ -s new ] || exit 0 - - # Print repository path and new tags - sed '1!s/^/\t/' -- path new - exit 1 - -) ; done |