[Fusionforge-commits] r15496 - in trunk/src: . plugins/scmgit/common

Franck VILLAUME nerville at fusionforge.org
Mon May 7 22:00:54 CEST 2012


Author: nerville
Date: 2012-05-07 22:00:53 +0200 (Mon, 07 May 2012)
New Revision: 15496

Modified:
   trunk/src/CHANGES
   trunk/src/plugins/scmgit/common/GitPlugin.class.php
Log:
new feature : scmgit now support activity

Modified: trunk/src/CHANGES
===================================================================
--- trunk/src/CHANGES	2012-05-07 19:56:43 UTC (rev 15495)
+++ trunk/src/CHANGES	2012-05-07 20:00:53 UTC (rev 15496)
@@ -4,6 +4,7 @@
 * Users: notify admins when user has validated his account (TrivialDev)
 * scmgit: add browsing capability for user personal repository (TrivialDev)
 * headermenu: new plugin to add links in login/logout menu link (TrivialDev)
+* scmgit: basic activity support (TrivialDev).
 
 FusionForge-5.2:
 * Docman: inject zip as a tree (Capgemini)

Modified: trunk/src/plugins/scmgit/common/GitPlugin.class.php
===================================================================
--- trunk/src/plugins/scmgit/common/GitPlugin.class.php	2012-05-07 19:56:43 UTC (rev 15495)
+++ trunk/src/plugins/scmgit/common/GitPlugin.class.php	2012-05-07 20:00:53 UTC (rev 15496)
@@ -38,6 +38,7 @@
 		$this->_addHook('scm_gather_stats');
 		$this->_addHook('widget_instance', 'myPageBox', false);
 		$this->_addHook('widgets', 'widgets', false);
+		$this->_addHook('activity');
 		$this->register();
 	}
 
@@ -687,6 +688,39 @@
 			}
 		}
 	}
+
+	function activity($params) {
+		$group_id = $params['group'];
+		$project = group_get_object($group_id);
+		if (! $project->usesPlugin($this->name)) {
+			return false;
+		}
+		if (in_array('scm', $params['show'])) {
+			$start_time = $params['begin'];
+			$end_time = $params['end'];
+			$repo = forge_get_config('repos_path', 'scmgit') . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git';
+			$pipe = popen("GIT_DIR=\"$repo\" git log --date=raw --since=@$start_time --until=@$end_time --all --pretty='format:%ad||%an||%s||%h' --name-status", 'r' );
+			while (!feof($pipe) && $data = fgets($pipe)) {
+				$line = trim($data);
+				$splitedLine = explode('||', $line);
+				if (sizeof($splitedLine) == 4) {
+					$result = array();
+					$result['section'] = 'scm';
+					$result['group_id'] = $group_id;
+					$result['ref_id'] = 'browser.php?group_id='.$group_id;
+					$result['description'] = $splitedLine[2].' (commit '.$splitedLine[3].')';
+					$result['realname'] = '';
+					$splitedDate = explode(' ', $splitedLine[0]);
+					$result['activity_date'] = $splitedDate[0];
+					$result['subref_id'] = '';
+					$params['results'][] = $result;
+				}
+			}
+		}
+		$params['ids'][] = 'scm';
+		$params['texts'][] = _('SCM Git Commits');
+		return true;
+	}
 }
 
 // Local Variables:




More information about the Fusionforge-commits mailing list