commit e78ab1e8c6aac0c42b4b191f04fcbde9d2c23291
parent 6b99d65e23db2593de4b53c592a9c1d4ae24b54f
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Tue, 16 Aug 2016 01:20:44 +0200
don't save latest revision in case of failure
Diffstat:
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/svn-poll b/svn-poll
@@ -15,6 +15,19 @@ URLFILE="$DIR/$HASH.url"
mkdir -p "$DIR"
+# just to remember
+echo "$URL" > "$URLFILE"
+
+LATEST="$(svn info "$URL" | grep Revision | cut -d' ' -f2)"
+
+# http://stackoverflow.com/a/806923/414272
+re='^[0-9]+$'
+if ! [[ $LATEST =~ $re ]] ; then
+ # importantly, don't save $LATEST then
+ echo "problem when fetching latest revision: got $LATEST" >&2
+ exit 1
+fi
+
if [[ -f "$FILE" ]]
then
SEEN=$(cat "$FILE")
@@ -22,14 +35,13 @@ else
SEEN=0
fi
-LATEST="$(svn info "$URL" | grep Revision | cut -d' ' -f2)"
-
if [[ "$SEEN" == "$LATEST" ]]
then
# nothing to do!
exit 0
fi
+# ok, so we have revisions to go over...
svn log --xml -r$(($SEEN+1)):$LATEST "$URL" |
xmlstarlet sel -t -m '//log/logentry' \
-v 'concat(@revision, " ", author/text())' -n |
@@ -55,7 +67,6 @@ do
fi
done
+# now that it's been processed, save it
echo "$LATEST" > "$FILE"
-echo "$URL" > "$URLFILE"
-