mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 04c0983c6464a9a4d8791851e243722fe0a360b2
parent 3727b0e20d6dad3d8a0e54a8aa4413a3a472f709
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 12 Aug 2016 03:06:56 +0200

init; save URL; avoid off-by-1

Diffstat:
svn-poll | 10+++++++++-
svn-poll-init | 19+++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/svn-poll b/svn-poll @@ -11,6 +11,7 @@ HASH=$(sha1sum <<<"$URL" | awk '{print $1}') DIR="$HOME/temp/svn-poll" FILE="$DIR/$HASH.rev" MUTEFILE="$DIR/$HASH.muted" +URLFILE="$DIR/$HASH.url" mkdir -p "$DIR" @@ -23,7 +24,13 @@ fi LATEST="$(svn info "$URL" | grep Revision | cut -d' ' -f2)" -svn log --xml -r$SEEN:$LATEST "$URL" | +if [[ "$SEEN" == "$LATEST" ]] +then + # nothing to do! + exit 0 +fi + +svn log --xml -r$(($SEEN+1)):$LATEST "$URL" | xmlstarlet sel -t -m '//log/logentry' \ -v 'concat(@revision, " ", author/text())' -n | while read revision author @@ -49,5 +56,6 @@ do done echo "$LATEST" > "$FILE" +echo "$URL" > "$URLFILE" diff --git a/svn-poll-init b/svn-poll-init @@ -0,0 +1,19 @@ +#!/bin/bash + +# initialize $URL without getting spammed by backlog +# inits to the current revision in an unmuted state + +URL="$1" +HASH=$(sha1sum <<<"$URL" | awk '{print $1}') +DIR="$HOME/temp/svn-poll" +FILE="$DIR/$HASH.rev" +URLFILE="$DIR/$HASH.url" + +mkdir -p "$DIR" + +LATEST="$(svn info "$URL" | grep Revision | cut -d' ' -f2)" + +echo "$LATEST" > "$FILE" +# just for future reference +echo "$URL" > "$URLFILE" +