2012-10-07 08:23:31 -04:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Generates an RSS feed from Git commit messages
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Mike Gerwitz
|
|
|
|
#
|
2012-10-07 11:22:49 -04:00
|
|
|
# This file is part of repo2html.
|
2012-10-07 08:23:31 -04:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# #
|
|
|
|
|
2012-10-08 22:19:55 -04:00
|
|
|
repotype="${1?Missing repository type}"
|
|
|
|
url="${2?Missing URL}"
|
2012-10-19 20:13:53 -04:00
|
|
|
count="${3:-0}"
|
2012-10-07 08:23:31 -04:00
|
|
|
|
2012-10-19 20:09:31 -04:00
|
|
|
# provide default message formatter if necessary
|
|
|
|
msgfmt="${msgfmt:-./msgfmt}"
|
|
|
|
|
2012-10-07 08:23:31 -04:00
|
|
|
# rss header
|
|
|
|
cat <<EOH
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<rss version="2.0">
|
|
|
|
<channel>
|
|
|
|
<title>Mike Gerwitz's Thoughts and Ramblings</title>
|
|
|
|
<link>$url</link>
|
|
|
|
<description>
|
|
|
|
The miscellaneous thoughts and ramblings of a free software hacker
|
|
|
|
</description>
|
|
|
|
EOH
|
|
|
|
|
|
|
|
|
|
|
|
# output recent commits as entries (assuming no funny business in the output)
|
2015-05-22 00:37:03 -04:00
|
|
|
IFS=$'\t'
|
|
|
|
while read hash commit ts id author email subject; do
|
2012-10-11 00:48:51 -04:00
|
|
|
# ignore commits that begin with ':'
|
|
|
|
[[ "$subject" == :* ]] && {
|
2013-03-10 22:49:45 -04:00
|
|
|
echo "Ignoring $commit: $subject" >&2
|
2012-10-11 00:48:51 -04:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2013-03-10 22:49:45 -04:00
|
|
|
echo "Found $commit: $subject" >&2
|
2012-10-07 08:23:31 -04:00
|
|
|
|
|
|
|
# TODO: avoid HTML entities where browsers may decide not to render them (e.g.
|
|
|
|
# the title)
|
|
|
|
cat <<EOE
|
|
|
|
<item>
|
2013-06-06 14:27:19 -04:00
|
|
|
<title><![CDATA[$( "$msgfmt" -nP < <( echo "$subject"; echo ) )]]></title>
|
2012-10-08 22:50:39 -04:00
|
|
|
<link>$(
|
|
|
|
printf "%s/%s/%s.html" \
|
2012-10-09 18:08:51 -04:00
|
|
|
"${url/%\/}" "$( ./tsdate "$ts" %Y/%m )" "$id"
|
2012-10-08 22:50:39 -04:00
|
|
|
)
|
|
|
|
</link>
|
|
|
|
<pubDate>$( ./tsdate "$ts" %Y-%m-%d )</pubDate>
|
2012-10-07 08:23:31 -04:00
|
|
|
<description>
|
|
|
|
<![CDATA[
|
2012-10-08 22:19:55 -04:00
|
|
|
$( ./"$repotype"/commit2html "$commit" )
|
2012-10-07 08:23:31 -04:00
|
|
|
]]>
|
|
|
|
</description>
|
|
|
|
</item>
|
|
|
|
EOE
|
2012-10-19 20:13:53 -04:00
|
|
|
|
|
|
|
# continue until we reach the requested number (note that we increment before
|
|
|
|
# the check, meaning that if the count is 0, then we will output every commit
|
|
|
|
((i++))
|
2013-03-10 22:40:52 -04:00
|
|
|
[ "$i" -eq "$count" ] && {
|
2013-03-10 22:49:45 -04:00
|
|
|
echo "Limit of $count reached." >&2
|
2013-03-10 22:40:52 -04:00
|
|
|
break
|
|
|
|
}
|
2012-10-08 22:19:55 -04:00
|
|
|
done
|
2012-10-07 08:23:31 -04:00
|
|
|
|
|
|
|
# footer
|
|
|
|
cat <<EOF
|
|
|
|
</channel>
|
|
|
|
</rss>
|
|
|
|
EOF
|