#!/bin/rc . /sys/lib/shithub/common.rc fn rssitem { puser=$1 prepo=$2 phash=$3 d=`{pwd} guid='http://'^$host/git/$puser/$prepo/commit/$phash message=`{htcat $gitfs/object/$phash/msg | sed 1q} description=`''{htcat $gitfs/object/$phash/msg} date=`{date -uf$dfmt `{mtime $gitfs/object/$phash/msg |awk '{print $1}'}} author=`"{sed 's/(.*) <(.*)>/\2 (\1)/g' < $gitfs/object/$phash/author} echo ' <item> <guid>'$"guid'</guid> <pubDate>'$"date'</pubDate> <title>'$"message'</title> <author>'$"author'</author> <link>'$guid'</link> <description><![CDATA[ <pre>'$description'</pre> ]]></description> </item>' cd $d} cd $1shift rfork nenl='' gituser=$1repo=$2refname=HEADdfmt='WW, DD MMM YYYY hh:mm:ss Z' repons $gituser $reporepodir=/mnt/$repo/.gitif(! ref=`{resolveref $refname}){ echo '<b>invalid ref '$refname'</b>' exit} if(test -f $gitfs/$ref/hash) hash=`{cat $gitfs/$ref/hash}if not hash=$ref http_response 'application/rss+xml'echo '<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <atom:link href="http://'$host/$gituser/$repo/'feed.rss" rel="self" type="application/rss+xml" /> <title>'$gituser/$repo' git log</title> <link>http://'$host'/git/'$gituser/$repo/'log/HEAD</link> <description>shithub git/log for repository '$gituser/$repo'</description> <lastBuildDate>'`"{date -uf$dfmt}'</lastBuildDate> <language>en-us</language>' if(! test -d $gitfs/$ref/tree){ echo ' </channel> </rss> ' exit}cd $gitfs/$ref/treecommithash=`{cat $gitfs/HEAD/hash | sed 1q}count=()while (! ~ $#commithash 0 && ! ~ $#count 10) { count=($count 1) rssitem $gituser $repo $commithash commithash=`{cat $gitfs/object/$commithash/parent | sed 1q}}echo ' </channel> </rss>'
#!/bin/rc
. /sys/lib/shithub/common.rc
fn rssitem {
puser=$1
prepo=$2
phash=$3
d=`{pwd}
guid='http://'^$host/git/$puser/$prepo/commit/$phash
message=`{htcat $gitfs/object/$phash/msg | sed 1q}
description=`''{htcat $gitfs/object/$phash/msg}
date=`{date -uf$dfmt `{mtime $gitfs/object/$phash/msg |awk '{print $1}'}}
author=`"{sed 's/(.*) <(.*)>/\2 (\1)/g' < $gitfs/object/$phash/author}
echo ' <item>
<guid>'$"guid'</guid>
<pubDate>'$"date'</pubDate>
<title>'$"message'</title>
<author>'$"author'</author>
<link>'$guid'</link>
<description><![CDATA[ <pre>'$description'</pre> ]]></description>
</item>'
cd $d
}
cd $1
shift
rfork ne
nl='
'
gituser=$1
repo=$2
refname=HEAD
dfmt='WW, DD MMM YYYY hh:mm:ss Z'
repons $gituser $repo
repodir=/mnt/$repo/.git
if(! ref=`{resolveref $refname}){
echo '<b>invalid ref '$refname'</b>'
exit
}
if(test -f $gitfs/$ref/hash)
hash=`{cat $gitfs/$ref/hash}
if not
hash=$ref
http_response 'application/rss+xml'
echo '<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://'$host/$gituser/$repo/'feed.rss" rel="self" type="application/rss+xml" />
<title>'$gituser/$repo' git log</title>
<link>http://'$host'/git/'$gituser/$repo/'log/HEAD</link>
<description>shithub git/log for repository '$gituser/$repo'</description>
<lastBuildDate>'`"{date -uf$dfmt}'</lastBuildDate>
<language>en-us</language>
'
if(! test -d $gitfs/$ref/tree){
echo ' </channel>
</rss>
'
exit
}
cd $gitfs/$ref/tree
commithash=`{cat $gitfs/HEAD/hash | sed 1q}
count=()
while (! ~ $#commithash 0 && ! ~ $#count 10) {
count=($count 1)
rssitem $gituser $repo $commithash
commithash=`{cat $gitfs/object/$commithash/parent | sed 1q}
}
echo ' </channel>
</rss>
'