[evolvis-commits] r18266: scmsvn-tweaks pending merges:↵ Thorsten Glaser 2012-04-10 [#2498] copy the old 4.8 scmsvn tasktracker cronjob

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Apr 10 16:37:27 CEST 2012


Author: mirabilos
Date: 2012-04-10 16:37:27 +0200 (Tue, 10 Apr 2012)
New Revision: 18266

Added:
   trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/
   trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/tasktrac.sh
   trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/cron.d/plugin-scmsvn
Modified:
   trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/install/plugin-scmsvn
Log:
scmsvn-tweaks pending merges:
  Thorsten Glaser 2012-04-10 [#2498] copy the old 4.8 scmsvn tasktracker cronjob

Added: trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/tasktrac.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/tasktrac.sh	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/tasktrac.sh	2012-04-10 14:37:27 UTC (rev 18266)
@@ -0,0 +1,159 @@
+#!/bin/mksh
+#-
+# Task/Tracker <-> SVN revision link support for FusionForge
+#
+# Copyright © 2010, 2011
+#	Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
+# All rights reserved.
+#
+# This file is part of FusionForge. FusionForge 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 2 of the Licence, or (at your option)
+# any later version.
+#
+# FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#-
+# Find out links between task/tracker items and SVN revisions,
+# and write them into a table, for the WUI to peruse.
+
+unset LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_IDENTIFICATION \
+    LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
+    LC_PAPER LC_TELEPHONE LC_TIME
+export LANG=C LC_CTYPE=en_US.UTF-8
+
+if (( USER_ID )); then
+	print -u2 Need superuser/root.
+	exit 1
+fi
+
+trace=0
+quiet=1
+while getopts "dt" ch; do
+	case $ch {
+	(d)	quiet=0 ;;
+	(+d)	quiet=1 ;;
+	(t)	trace=1 ;;
+	(+t)	trace=0 ;;
+	(*)	print -u2 Syntax error.; exit 1 ;;
+	}
+done
+shift $((OPTIND - 1))
+
+#XXX put these into a dpkg-conffile
+SVNROOT=/scmrepos/svn
+
+set -A repos
+set -A revs
+set -A logs
+i=0
+
+cd $SVNROOT
+for dir in *; do
+	(( quiet )) || print Trying $dir...
+	[[ -e $SVNROOT/$dir ]] || continue
+	cd $SVNROOT/$dir
+	oldrev=0
+	[[ -s evolvis-plugin-scmsvn.state.tasktrac ]] && \
+	    oldrev=$(<evolvis-plugin-scmsvn.state.tasktrac)
+	[[ $oldrev = +([0-9]) ]] || oldrev=0
+	newrev=$(svnlook youngest .)
+	(( quiet )) || print From $oldrev to $newrev...
+	while (( ++oldrev <= newrev )); do
+		log=$(svnlook log -r$((oldrev)) .)
+		if [[ $log != *'[#'+([0-9])']'* ]]; then
+			(( quiet )) || print -r skipping r$((oldrev)): \
+			    "「$log」"
+			continue
+		fi
+		(( quiet )) || print -r found r$((oldrev)): "「$log」"
+		repos[i]=$dir
+		revs[i]=$((oldrev))
+		logs[i++]=$log
+	done
+	print -- $((newrev)) >evolvis-plugin-scmsvn.state.tasktrac
+	(( quiet )) || print Reached r$((newrev)), done.
+done
+(( quiet )) || print Processed all repositories.
+
+if (( !quiet )); then
+	j=0
+	print DEBUG output
+	while (( j < i )); do
+		print -r -- "${repos[j]}/${revs[j]}=「${logs[j]}」"
+		let ++j
+	done
+	print DEBUG end
+fi
+
+if (( !i )); then
+	(( quiet )) || print no results found, exiting
+	exit 0
+fi
+
+nl='
+'
+
+function escape_string_into_php {
+	typeset s="$*"
+
+	# double all backslashes
+	s=${s//\\/\\\\}
+	# escape single quotes and enclose string in them
+	print -r -- "'${s//\'/\\\'}'"
+}
+
+function array_to_php {
+	typeset aname=$1 i=0 len x
+
+	eval 'len=${#'$aname'[*]}'
+	print -r -- "\$$aname = array("
+	while (( i < len )); do
+		eval 'x=${'$aname'[i++]}'
+		print -r -- "	$(escape_string_into_php "$x"),"
+	done
+	print ");"
+}
+
+phpcode=$(cat) <<'EOF'
+require 'www/env.inc.php';
+require_once $gfwww.'include/squal_pre.php';
+require_once $gfcommon.'pm/ProjectTaskSqlQueries.php';
+
+EOF
+phpcode=$phpcode"\$imax = $i;"$nl
+phpcode=$phpcode$(array_to_php repos)$nl
+phpcode=$phpcode$(array_to_php revs)$nl
+phpcode=$phpcode$(array_to_php logs)$nl
+phpcode=$phpcode$(cat) <<'EOF'
+
+$i = -1;
+while (++$i < $imax) {
+	$matches = array();
+	preg_match_all('|\[#([0-9]+)]|', $logs[$i], $matches);
+	$link = util_make_url('/scm/viewvc.php?view=rev&root=' .
+	    $repos[$i] . '&revision=' . $revs[$i]);
+	foreach (array_unique($matches[1]) as $id) {
+		if (!tasktracker_gettype($id))
+			continue;
+		$res = db_query_params('INSERT INTO tasktracker_scm
+			(id, group_name, revision, href)
+			VALUES ($1, $2, $3, $4)', array(
+			(int)$id, $repos[$i], (int)$revs[$i], $link));
+		if (!$res || db_affected_rows($res) != 1)
+			echo "Error linking [#" . $id . "] => " . $repos[$i] .
+			    "/" . $revs[$i] . ": " . db_error() . "\n";
+	}
+}
+EOF
+
+(( trace )) && print -r "DEBUG: dumping php code: 「$nl$phpcode$nl」"
+php -d include_path="$INCLUDE_PATH" -r "$phpcode" >&2
+exit 0


Property changes on: trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/cronjobs/tasktrac.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/cron.d/plugin-scmsvn
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/cron.d/plugin-scmsvn	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/cron.d/plugin-scmsvn	2012-04-10 14:37:27 UTC (rev 18266)
@@ -0,0 +1,2 @@
+# Task/Tracker links
+*/12 * * * * root [ -x /usr/share/gforge/plugins/scmsvn/cronjobs/tasktrac.sh ] && /usr/share/gforge/plugins/scmsvn/cronjobs/tasktrac.sh 2>&1 | logger -t evolvis-plugin-scmsvn:cron:tasktrac

Modified: trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/install/plugin-scmsvn
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/install/plugin-scmsvn	2012-04-10 14:37:24 UTC (rev 18265)
+++ trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/packaging/install/plugin-scmsvn	2012-04-10 14:37:27 UTC (rev 18266)
@@ -1,4 +1,5 @@
 plugins/scmsvn/bin/*                usr/share/@OLDPACKAGE@/plugins/scmsvn/bin/
 plugins/scmsvn/common/*             usr/share/@OLDPACKAGE@/plugins/scmsvn/common/
+plugins/scmsvn/cronjobs/*           usr/share/@OLDPACKAGE@/plugins/scmsvn/cronjobs/
 plugins/scmsvn/etc/plugins/scmsvn/* etc/@OLDPACKAGE@/plugins/scmsvn/
 plugins/scmsvn/etc/*.ini 	    etc/@PACKAGE@/config.ini.d/



More information about the evolvis-commits mailing list