mybin

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

commit 3727b0e20d6dad3d8a0e54a8aa4413a3a472f709
parent 80070f4e20ec228b1b74bec8e7af401a9f0a3f58
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 12 Aug 2016 02:49:16 +0200

svn-poll

Diffstat:
svn-poll | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
svn-poll-drop | 11+++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/svn-poll b/svn-poll @@ -0,0 +1,53 @@ +#!/bin/bash + +# print svn log of changes in repository $URL (except those of $USER) +# since the latest time svn-poll was called on that repository +# once a log has been shown, svn-poll will shut up until $USER commits +# or svn-poll-drop is called + +URL="$1" +USER="$2" +HASH=$(sha1sum <<<"$URL" | awk '{print $1}') +DIR="$HOME/temp/svn-poll" +FILE="$DIR/$HASH.rev" +MUTEFILE="$DIR/$HASH.muted" + +mkdir -p "$DIR" + +if [[ -f "$FILE" ]] +then + SEEN=$(cat "$FILE") +else + SEEN=0 +fi + +LATEST="$(svn info "$URL" | grep Revision | cut -d' ' -f2)" + +svn log --xml -r$SEEN:$LATEST "$URL" | + xmlstarlet sel -t -m '//log/logentry' \ + -v 'concat(@revision, " ", author/text())' -n | + while read revision author +do + if [[ -f "$MUTEFILE" ]] + then + # we are muted (have notified a change already) + # if we committed, we unmute + if [[ "$author" == "$USER" ]] + then + rm -f "$MUTEFILE" + fi + else + # we are not muted: if someone else than us committed, + # we notify and mute + if [[ "$author" != "$USER" ]] + then + # notify the revision + svn log -v -r$revision "$URL" + touch "$MUTEFILE" + fi + fi +done + +echo "$LATEST" > "$FILE" + + diff --git a/svn-poll-drop b/svn-poll-drop @@ -0,0 +1,11 @@ +#!/bin/bash + +# say we are interested again in $URL + +URL="$1" +HASH=$(sha1sum <<<"$URL" | awk '{print $1}') +DIR="$HOME/temp/svn-poll" +MUTEFILE="$DIR/$HASH.muted" + +rm -f "$MUTEFILE" +