Home » Community » U++ community news and announcements » Svn changes over RSS feed
Re: Svn changes over RSS feed [message #25152 is a reply to message #25044] |
Fri, 12 February 2010 19:57   |
|
Hello all!
I had some free time today, so I decided make a little exercise in sed:#!/bin/bash
SVNPATH="/path/to/svn"
COUNT="25"
OUTPUT="/tmp/svnchanges.html"
header='1 c<html><head><script>\
function toggleFiles(id){\
var f=document.getElementById("f"+id);var a=document.getElementById("a"+id);\
if(f.style.display=="none"){f.style.display="block";a.innerHTML="Hide affected files";}\
else{f.style.display="none";a.innerHTML="Show affected files"}}\
</script></head><body>
# replace first line with header'
footer='$ a</body></html>
# append footer after last line'
svn --limit $COUNT --verbose log $SVNPATH |\
sed -n \
-e "$header" \
-e '/-----*/ !{ # when the line IS NOT separator
s/^ *A \(.*$\)/\1 (Added)<br>/
s/^ *M \(.*$\)/\1 (Modified)<br>/ # formating of affected files
s/^ *D \(.*$\)/\1 (Removed)<br>/
H #append everything between separators into hold space
}' \
-e '/-----*/ { # when the line IS separator
x # get string from hold space
s/r\([0-9]*\)[ |]*\([^|]*\)[ |]*\([0-9 :+\-]*\).*\nChanged paths:\n\(.*\)\n\n\(.*\)$/\
<table style="font-size:small;">\
<tr><td>Revision:<\/td><td><b>\1<\/b><\/td><\/tr>\
<tr><td>Description:<\/td><td><code>\5<\/code><\/td><\/tr>\
<tr><td>Submitted:<\/td><td><i>\3<\/i> by <i>\2<\/i><\/td><\/tr>\
<tr><td colspan="2">\
<a href="" id="a\1" onclick="toggleFiles(\1);return false;">Show affected files<\/a>\
<div id="f\1" style="display:none;margin-left:20px;">\4<\/div>\
<\/td><\/tr>\
<\/table><br>\
/p # this ugly substitution makes all the formating
s/.*// # clear pattern space
x # clear hold space
}' \
-e "$footer" > $OUTPUT
This script parses svn log into static html, which I hope will be simple to include somewhere in the pages (<iframe>?). It's just a "first iteration", so please don't look at the style too much It will need few touches to get it in look fitting on the web, but that is the easier part.
I hope that thee three variables on top of the script are self-explaining, so anyone can try this at home Looking forward to your comments.
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Tue Apr 29 22:01:52 CEST 2025
Total time taken to generate the page: 0.04321 seconds
|