Conversor de logs do svn para rss

Publicado por Pedro Robson Leão 29/10/2008

[ Hits: 4.182 ]

Download snvlog2rss.sh




<pre>
script -h (help)

uso: script >file.xml

Os seguintes parâmetros podem estar incluídos em um arquivo /home/pleao/../snvlog2rss.sh.rc
</pre>

  



Esconder código-fonte

<pre>
#default
action="SNV_CHANGE";
webrepository="http://localhost/svnwebclient/content.jsp";
webparam="crev";
domain="localhost";
title="SVN TAGS";
description="Tags SVN";
lang="pt-br";
repository="http://svn/repositorio";
revisions=20;

function manpage() {
    cat ${1} | grep "##" | grep -v cat | cut -c 3- | while read line ; do
        eval "echo \"${line}\"";
    done
    exit;
}
###############################################
## Pedro Robson Leao - 20081021
##
## Conversor de log svn para rss
##
## Versao 1.0
##
## uso: script >file.xml
##
## Os seguinte parametros podem estar incluidos em um arquivo ${HOME}/.${0}.rc
##
###acao incluida no xml
##action="SNV_CHANGE";
###url do snvwebclient ou similar #testado com svnwebclient
##webrepository="http://localhost/svnwebclient/content.jsp";
###parametro para pegar revisao na interface web do controlador de versao
##webparam="crev";
###domain para os usuarios - composicao do email
##domain="localhost";
###titulo do rss
##title="SVN TAGS";
###descricao do rss
##description="Tags SVN";
###language do rss
##lang="pt-br";
###endereco do repositorio
##repository="http://svn/repositorio";
###quantidade de revisoes para ser verificada
##revisions=20;
################################################

[ "${1}" == "-h" ] && manpage "${0}";

rev=$( svn --non-interactive info ${repository} | grep ^Revision: | cut -d : -f 2 );

rev2=$((rev-revisions));

[ "${rev2}" -lt "0" ] && {
    rev2=0;
}

[ -f ~/.${0}.rc ] && {
    source  ~/.${0}.rc;
}

date=$(date +%Y%m%d );

svn --non-interactive log ${repository} -r ${rev}:${rev2} -v | awk \
-v action="${action}" \
-v webrepository="${webrepository}" \
-v webparam="${webparam}" \
-v domain="${domain}" \
-v title="${title}" \
-v description="${description}" \
-v lang="${lang}" \
-v date="${date}" \
'
BEGIN {
#    x=i="a";
#    action="SNV_CHANGE";
#    webrepository="http://csaad:8085/svnwebclient/content.jsp";
#    webparam="crev";
#    domain="okto.com.br";
#    title="SVN TAGS";
#    description"Tags SVN";
#    lang="pt-br";
#    date="20081020";

    STATUS[" "] =  "no modifications";
    STATUS["A"]  = "Added";
    STATUS["C"]  = "Conflicted";
    STATUS["D"]  = "Deleted";
    STATUS["I"]  = "Ignored";
    STATUS["M"]  = "Modified";
    STATUS["R"]  = "Replaced";
    STATUS["X"]  = "item is unversioned, but is used by an externals definition";
    STATUS["?"]  = "item is not under version control";
    STATUS["!"]  = "item is missing (removed by non-svn command) or incomplete";
    STATUS["~"]  = "versioned item obstructed by some item of a different kind";

   print "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" >";

    print "<channel>";
    print "<title>" title "</title>";
    print "<link>" webrepository "</link>";
    print "<description>" description "</description>";
    print "<pubDate>" date "</pubDate>";

    print "<generator>http://wordpress.org/?v=MU</generator>";
    print "<language>" lang "</language>";
}
function mount_item() {

    repository = webrepository;

    if(webparam) {
        repository = sprintf("%s%s%s%s%s", repository, "?", webparam, "=", release);
    }


    if(domain) {
        user = sprintf("%s@%s", user, domain);
    }

    print "<item>";
    print "    <title>Revision " release, "by", user"</title>";
    print "    <link>", repository, "</link>"; #trocar parametrizavel
    print "    <dc:creator>" user "</dc:creator>";
    print "    <pubDate>" date, hour "</pubDate>";
    print "    <category><![CDATA[",action,"]]></category>";

    print "    <description><![CDATA[";
    print ":: <b>Links:</b><br>";
    for (s in _src) {
        if(_src[s]) {
            a=_action[s];
            status = STATUS[a] ?  STATUS[a] : a;
            print "<b>" status "</b>: " "<a href=" repository "&url=" substr(_src[s],2) ">" _src[s] "</a><br>";
        }
        _src[s]=0;
    }
    print "<br><br>:: <b>Info:</b><br>";
    for (c in comment) {
        if(comment[c]) {
            #if(!index(coment[c],"<br>$")) {
            #    print comment[c];
            #} else {
                print comment[c], "<br>";
            #}
        }
        comment[c]=0;
    }
    print "    <hr>]]></description>";
    print "</item>";
}

/^---------/ { #start
    if(flg) {
        mount_item();
        i=x="a";
    }

    flg=1;
}

/r[0-9]/ { #release
#r3075 | pleao | 2008-10-17 11:53:08 -0300 (Fri, 17 Oct 2008) | 7 lines
    release=substr($1,2);
    user=$3;
    date=$5;
    hour=$6;
    tz=$4;
}

/Changed paths:/ {
#tira o changed paths
}

/^   [A-Z] \// { #Changed paths:
#   M /legacy/gkpromo/trunk/interface/front-end/default.css
    _action[i]=$1;
    _src[i]=$2;
    i++;
}

{
    comment[x]=$0;
    x++;
}
END {
    mount_item();
    print "</channel></rss>";
}
';

</pre>

Scripts recomendados

Gravar DVDs no Linux pelo Cron

package maker para o slackware

Configurando um Domínio no BIND9 com Debian 3.1

Automatizando o Nagios

Atualização do FreeBSD


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts