[Fusionforge-commits] FusionForge branch Branch_5_3 updated. 634a3108c60dd1af293a4f95d5230ace20a5aee3

Alain Peyrat aljeux at fusionforge.org
Mon Jun 2 13:46:19 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, Branch_5_3 has been updated
       via  634a3108c60dd1af293a4f95d5230ace20a5aee3 (commit)
      from  552b2ec929de3c35c3bd5dcdaf92d925b7bc7a06 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 634a3108c60dd1af293a4f95d5230ace20a5aee3
Author: Alain Peyrat <alain.peyrat at alcatel-lucent.com>
Date:   Mon Jun 2 13:43:40 2014 +0200

    scmhook: git tracker - Search author using email or realname if username is not working

diff --git a/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php b/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
index a49a556..6600339 100755
--- a/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
+++ b/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
@@ -121,6 +121,7 @@ $git_tracker_debug = 0;
 chdir($repo_path);
 
 $UserName = trim(`git log -n 1 --format=%an $newrev`);
+$email    = trim(`git log -n 1 --format=%ae $newrev`);
 $date     = trim(`git log -n 1 --format=%ai $newrev`);
 $log      = trim(`git log -n 1 --format=%s $newrev`);
 $changed  = trim(`git log -n 1 --format=%b --name-only -p $newrev`);
@@ -131,6 +132,7 @@ if (isset($git_tracker_debug) && $git_tracker_debug == 1) {
 	fwrite($file,"arg :  " . print_r($argv,true) . " \n");
 	fwrite($file,"rev :  " . $newrev . " \n");
 	fwrite($file,"username :  " . $UserName . " \n");
+	fwrite($file,"email :  " . $email . " \n");
 	fwrite($file,"date :  " . $date . " \n");
 	fwrite($file,"log  :  " . $log . " \n");
 	fwrite($file,"changed :  " . $changed . " \n");
@@ -185,6 +187,7 @@ $i = 0;
 foreach ( $files as $onefile )
 {
 	$SubmitVars[$i]["UserName"]        = $UserName;
+	$SubmitVars[$i]["Email"]           = $email;
 	$SubmitVars[$i]["Repository"]      = $repo_path;
 	$SubmitVars[$i]["FileName"]        = $onefile['name'];
 	$SubmitVars[$i]["PrevVersion"]     = $onefile['previous'];
@@ -198,4 +201,4 @@ foreach ( $files as $onefile )
 
 $vars['data'] = urlencode(serialize($SubmitVars));
 $snoopy->submit($SubmitUrl, $vars);
-?>
+// echo $snoopy->results;
diff --git a/src/plugins/scmhook/www/committracker/newcommitgit.php b/src/plugins/scmhook/www/committracker/newcommitgit.php
index a1c17c7..a056e11 100644
--- a/src/plugins/scmhook/www/committracker/newcommitgit.php
+++ b/src/plugins/scmhook/www/committracker/newcommitgit.php
@@ -47,6 +47,7 @@ if(is_array($SubmittedVars)) {
 	foreach ($SubmittedVars as $SubmittedVar) {
 		$Configs[$i] = array();
 		$Configs[$i]['UserName']        = $SubmittedVar['UserName'];
+		$Configs[$i]['Email']           = $SubmittedVar['Email'];
 		//$Configs[$i]['UserName']        = 'def_admin';   use this to make tests, just replace with a gforge user
 		$Configs[$i]['Repository']      = $SubmittedVar['Repository'];
 		$Configs[$i]['FileName']        = $SubmittedVar['FileName'];
@@ -78,6 +79,7 @@ function parseConfig(&$Config)
 	$Result['check'] = true;
 	$Repository = $Config['Repository'];
 	$UserName = $Config['UserName'];
+	$email = $Config['Email'];
 
 	if($repos_path[strlen($repos_path)-1]!='/') {
 		$repos_path.='/';
@@ -107,8 +109,20 @@ function parseConfig(&$Config)
 
 	if (!$Result['user'] || !is_object($Result['user']) ||
 		$Result['user']->isError() || !$Result['user']->isActive()) {
-		$Result['check'] = false;
-		$Result['error'] = 'Invalid User';
+
+		// Try searching using real name or email address instead.
+		$res=db_query_params('SELECT user_name FROM users WHERE lower(realname)=$1 OR lower(email)=$2',
+			array(strtolower($UserName), strtolower($email)));
+		if ($res && db_numrows($res) > 0) {
+			$Config['UserName'] = db_result($res,0,'user_name');
+			$Result['user'] = user_get_object_by_name($Config['UserName']);
+		}
+
+		if (!$Result['user'] || !is_object($Result['user']) ||
+			$Result['user']->isError() || !$Result['user']->isActive()) {
+			$Result['check'] = false;
+			$Result['error'] = 'Invalid User';
+		}
 	}
 	return $Result;
 }

-----------------------------------------------------------------------

Summary of changes:
 .../library/scmgit/hooks/committracker/post.php      |    5 ++++-
 .../scmhook/www/committracker/newcommitgit.php       |   18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list