From: Rudolf Polzer Date: Mon, 14 May 2012 13:31:07 +0000 (+0200) Subject: add a conflict detector that outputs to per-branchowner RSS feeds X-Git-Tag: xonotic-v0.7.0~55^2~18 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d60e3109a47b62fc78815e8c3e54da84b038429;p=xonotic%2Fxonotic.git add a conflict detector that outputs to per-branchowner RSS feeds --- diff --git a/misc/tools/conflict-rss.sh b/misc/tools/conflict-rss.sh new file mode 100755 index 00000000..5b61861a --- /dev/null +++ b/misc/tools/conflict-rss.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +set -e + +action=$1 +outdir=$2 +repodir=$3 + +branches() +{ + git for-each-ref 'refs/remotes' | grep -vE ' refs/remotes/([^/]*/HEAD|.*/archived/.*)$' +} + +escape_html() +{ + sed -e 's/&/\&/g; s//>/g' +} + +to_rss() +{ + outdir=$1 + name=$2 + hash=$3 + branch=$4 + + filename=$outdir/`echo -n "$name" | tr -c 'A-Za-z0-9' '_'`.xml + datetime=`date --rfc-2822` + branch=`echo "$branch" | escape_html` + + if ! [ -f "$filename" ]; then + cat >"$filename" < + + + Merge conflicts for $name + ... + ... + $datetime + 3600 +EOF + fi + cat >>"$filename" < + $branch ($hash) + ... + >"$filename" + + cat >>"$filename" < + +EOF +} + +finish_rss() +{ + cat <>"$1" + + +EOF +} + +if [ -z "$outdir" ]; then + set -- +fi + +case "$action" in + --init) + rm -rf "$outdir" + mkdir -p "$outdir" + ;; + --finish) + for f in "$outdir"/*; do + [ -f "$f" ] || continue + finish_rss "$f" + done + ;; + --add) + ( + if [ -n "$repodir" ]; then + cd "$repodir" + fi + branches + ) | while read -r HASH TYPE REFNAME; do + echo >&2 -n "$repodir $REFNAME..." + out=$( ( + if [ -n "$repodir" ]; then + cd "$repodir" + fi + git reset --hard >/dev/null 2>&1 + if out=`git merge --no-commit -- "$REFNAME" 2>&1`; then + good=true + else + good=false + echo "$out" + fi + git reset --hard >/dev/null 2>&1 + ) ) + if [ -n "$out" ]; then + n=${REFNAME#refs/remotes/[^/]*/} + case "$n" in + */*) + b=${n#*/} + n=${n%%/*} + ;; + *) + b="/$n" + n=divVerent + ;; + esac + echo "$out" | to_rss "$outdir" "$n" "$HASH" "$b" + echo >&2 " CONFLICT" + else + echo >&2 " ok" + fi + done + ;; + *) + echo "Usage: $0 --init OUTDIR" + echo " $0 --add OUTDIR [REPODIR]" + echo " $0 --finish OUTDIR" + exit 1 + ;; +esac