aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-11-30 17:04:02 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-11-30 17:04:02 +1300
commit0c8b79bd53e1ff75c5a96a6dc018adb9da6e380b (patch)
treebb3d806d0d86bae5f74bd86a9fb5e59dca85c57b
parentMerge branch 'release/v3.1.0' into develop (diff)
downloadwatch-vcs-tags-0c8b79bd53e1ff75c5a96a6dc018adb9da6e380b.tar.gz
watch-vcs-tags-0c8b79bd53e1ff75c5a96a6dc018adb9da6e380b.zip
Refactor script some more
-rwxr-xr-xwatch-git-tags34
1 files changed, 20 insertions, 14 deletions
diff --git a/watch-git-tags b/watch-git-tags
index e7d2c59..b2b1fa8 100755
--- a/watch-git-tags
+++ b/watch-git-tags
@@ -2,14 +2,14 @@
self=watch-git-tags
# List sorted local tags
-local_tags() {
+tags_local() {
for repo ; do
git -C "$repo" tag --list | LC_COLLATE=C sort
done
}
# List sorted remote tags
-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"
@@ -39,25 +39,25 @@ done
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
+ 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
- local_tags "$repo" > "$sd"/a || exit
- remote_tags "$repo" > "$sd"/b || exit
+ tags_local "$repo" > tags/local || exit
+ tags_remote "$repo" > tags/remote || exit
# Write new tags to file
- LC_COLLATE=C comm -13 -- [ab] > new
+ 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 new ] || continue
+ [ -s tags/new ] || continue
git -C "$repo" fetch --quiet --tags
) & done
@@ -67,13 +67,19 @@ wait
# Iterate through the temp dirs in order
for dir in "$td"/* ; do (
- cd -- "$dir" || exit 0
+ cd -- "$dir" || exit
# Look for non-zero "new" files (at least one new tag)
- [ -s new ] || exit 0
+ [ -s tags/new ] || exit
# Print repository path and new tags
- sed '1!s/^/\t/' -- path new
- exit 1
+ 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