]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/conflict-rss.sh
more fixes
[xonotic/xonotic.git] / misc / tools / conflict-rss.sh
index 5ad6d33513c00e25c75e724fea238ff87e6b15a2..c64fffdb6e67d0258f48491b34aea680e930bd4a 100755 (executable)
@@ -21,41 +21,48 @@ to_rss()
        outdir=$1
        name=$2
        masterhash=$3
-       hash=$4
-       branch=$5
-       repo=$6
-       if [ -n "$repo" ]; then
-               repo=" in $repo"
-       fi
+       masterbranch=$4
+       hash=$5
+       branch=$6
+       repo=$7
 
-       filename=`echo -n "$name" | tr -c 'A-Za-z0-9' '_'`.xml
+       filename=`echo -n "$name" | tr -c 'A-Za-z0-9' '_'`.rss
        outfilename="$outdir/$filename"
-       datetime=`date --rfc-2822`
-       branch=`echo "$branch" | escape_html`
-       repo=`echo "$repo" | escape_html`
+       masterbranch=`echo -n "$masterbranch" | escape_html`
+       branch=`echo -n "$branch" | escape_html`
+       repo=`echo -n "$repo" | escape_html`
+       if [ -n "$repo" ]; then
+               repotxt=" in $repo"
+       else
+               repotxt=
+       fi
 
        if ! [ -f "$outfilename" ]; then
+               datetime=`date --rfc-2822`
                cat >"$outfilename" <<EOF
 <?xml version="1.0" encoding="UTF-8" ?>
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
-       <title>Merge conflicts for $name</title>
+       <title>XonCW: $name</title>
        <link>http://git.xonotic.org/</link>
-       <description>...</description>
-       <lastBuildDate>$datetime</lastBuildDate>
+       <description>Xonotic Conflict Watch for branches by $name</description>
        <ttl>3600</ttl>
        <atom:link href="http://de.git.xonotic.org/conflicts/$filename" rel="self" type="application/rss+xml" />
+       <lastBuildDate>$datetime</lastBuildDate>
 EOF
        fi
        cat >>"$outfilename" <<EOF
        <item>
-               <title>$branch$repo ($hash)</title>
-               <link>http://git.xonotic.org/?p=xonotic/netradiant.git;a=shortlog;h=refs/heads/$name/$branch</link>
-               <guid isPermaLink="false">http://de.git.xonotic.org/conflicts/$filename#$hash-$masterhash</guid>
+               <title>$branch$repotxt</title>
+               <link>http://git.xonotic.org/?p=$repo;a=shortlog;h=refs/heads/$name/$branch</link>
+               <guid isPermaLink="false">http://de.git.xonotic.org/conflicts/$filename#$hash</guid>
                <description><![CDATA[
+               Conflicts of $branch at $hash against $masterbranch at $masterhash:
 EOF
-
+       echo -n "<pre>" >>"$outfilename"
        escape_html >>"$outfilename"
+       echo "</pre>" >>"$outfilename"
 
        cat >>"$outfilename" <<EOF
                ]]></description>
@@ -63,6 +70,15 @@ EOF
 EOF
 }
 
+clear_rss()
+{
+       datetime=`date --rfc-2822`
+       sed -i -e '/<lastBuildDate>/,$d' "$1"
+       cat <<EOF >>"$1"
+       <lastBuildDate>$datetime</lastBuildDate>
+EOF
+}
+
 finish_rss()
 {
        cat <<EOF >>"$1"
@@ -75,10 +91,22 @@ if [ -z "$outdir" ]; then
        set --
 fi
 
+repo=$(
+       (
+               if [ -n "$repodir" ]; then
+                       cd "$repodir"
+               fi
+               git config remote.origin.url | cut -d / -f 4-
+       )
+)
+
 case "$action" in
        --init)
-               rm -rf "$outdir"
                mkdir -p "$outdir"
+               for f in "$outdir"/*; do
+                       [ -f "$f" ] || continue
+                       clear_rss "$f"
+               done
                ;;
        --finish)
                for f in "$outdir"/*; do
@@ -95,13 +123,22 @@ case "$action" in
                                git rev-parse HEAD
                        )
                )
+               masterbranch=$(
+                       (
+                               if [ -n "$repodir" ]; then
+                                       cd "$repodir"
+                               fi
+                               git symbolic-ref HEAD
+                       )
+               )
+               masterbranch=${masterbranch#refs/heads/}
                (
                        if [ -n "$repodir" ]; then
                                cd "$repodir"
                        fi
                        branches
                ) | while read -r HASH TYPE REFNAME; do
-                       echo >&2 -n "$repodir $REFNAME..."
+                       echo >&2 -n "$repo $REFNAME..."
                        out=$(
                                (
                                        if [ -n "$repodir" ]; then
@@ -127,7 +164,7 @@ case "$action" in
                                                n=divVerent
                                                ;;
                                esac
-                               echo "$out" | to_rss "$outdir" "$n" "$masterhash" "$HASH" "$b" "$repodir"
+                               echo "$out" | to_rss "$outdir" "$n" "$masterhash" "$masterbranch" "$HASH" "$b" "$repo"
                                echo >&2 " CONFLICT"
                        else
                                echo >&2 " ok"