function displayScmHook($group_id, $scm) {
global $HTML;
use_javascript('/js/sortable.js');
- # commenté pour cause d'erreur dans la page d'admin
-#[8] Undefined variable: HTML (/home/ben/trivialdev/repos/scmhook/tiben/src/plugins/scmhook/common/scmhookPlugin.class.php at 132)
-#does not end with </html> tag
-#does not end with </body> tag
-#The output has ended thus: cm_enable_anonymous" value="1" checked="checked" /><strong>Enable Anonymous Read Access</strong></p>
- #echo $HTML->getJavascripts();
+ echo $HTML->getJavascripts();
$hooksAvailable = $this->getAvailableHooks($group_id);
$statusDeploy = $this->getStatusDeploy($group_id);
$hooksEnabled = $this->getEnabledHooks($group_id);
}
function isAvailable() {
- if ($this->group->usesTracker()) {
- return true;
+ if (!$this->group->usesTracker()) {
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project not using tracker.');
+ return false;
+ } elseif (!forge_get_config('use_ssh','scmgit')) {
+ $this->disabledMessage = _('Hook not available due to missing dependency : Forge not using ssh for git.');
+ return false;
}
- $this->disabledMessage = _('Hook not available due to missing dependency : Project not using tracker.');
- return false;
+ return true;
}
function getDisabledMessage() {
echo '<tr><td>';
echo '<h2>'._('Related GIT commits').'</h2>';
- $title_arr = $this->getTitleArr();
+ $title_arr = $this->getTitleArr($group_id);
echo $GLOBALS['HTML']->listTableTop($title_arr);
for ($i=0; $i<$Rows; $i++) {
* @return Array The array containing the titles
*
*/
- function getTitleArr() {
+ function getTitleArr($group_id) {
$title_arr=array();
- $title_arr[]=_('Filename');
+//http://tiben.info/scm/browser.php?group_id=10
+ $title_arr[]=_('Filename (<a href="/scm/browser.php?group_id='.$group_id.'">Broswe</a>)');
$title_arr[]=_('Date');
$title_arr[]=_('Previous Version');
$title_arr[]=_('Current Version');
*
*/
function getFileLink($GroupName, $FileName, $LatestRevision) {
- return util_make_link ('/scm/viewvc.php'.$FileName .
- '?root='.$GroupName.'&view=log&rev=' .
- $LatestRevision,
- $FileName) ;
+ return $FileName;
}
/**
*
*/
function getActualVersionLink($GroupName, $FileName, $Version) {
- return util_make_link ('/scm/viewvc.php'.$FileName .
- '?root='.$GroupName.'&rev='.$Version,
- $Version);
+ return $Version;
}
/**
*
*/
function getDiffLink($GroupName, $FileName, $PrevVersion, $ActualVersion) {
- return util_make_link ('/scm/viewvc.php'.$FileName .
- '?root='.$GroupName.'&r1='.$PrevVersion .
- '&r2='.$ActualVersion,
- _('Diff To').' '.$PrevVersion);
+ return $PrevVersion;
}
}
* The rest Copyright 2004 (c) Francisco Gimeno <kikov @nospam@ kikov.org>
* Copyright 2011, Franck Villaume - Capgemini
* Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2014, Benoit Debaenst - TrivialDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
exit;
}
-$oldrev = $argv[1];
-$newrev = $argv[2];
-$refname = $argv[3];
-$hook_path=$argv[4];
-//$repository = $argv[1];
-//$revision = $argv[2];
-$git_tracker_debug = 1;
-//cd /var/opt/fusionforge/chroot/scmrepos/git/projet02/projet02.git
-$repos_path=forge_get_config('repos_path','scmgit');
-//var_dump($repos_path);
-//var_dump($refname);
-//echo "hook path ::::: ";
-//var_dump($hook_path);
-chdir($hook_path.'/..');
-//git show --pretty=short bed85a02ce30d35e44bd2f6b1020aabe53b16ce5
-$UserName = trim(`git log -n 1 --format=%an $newrev`);
+$oldrev = $argv[1];
+$newrev = $argv[2];
+$refname = $argv[3];
+$repo_path = substr_replace($argv[4],'',-6);
+
+$git_tracker_debug = 0;
+
+chdir($repo_path);
-//$UserName = trim(`svnlook author -r $revision $repository`); //username of author
-//$date = trim(`svnlook date -r $revision $repository`); //date
-$date = trim(`git log -n 1 --format=%ai $newrev`); //date
-$log = trim(`git log -n 1 --format=%s $newrev`); // the log
-//echo $log;
-//var_dump($log);
-$changed = trim(`git log -n 1 --format=%b --name-only -p $newrev`); // the filenames
+$UserName = trim(`git log -n 1 --format=%an $newrev`);
+$date = trim(`git log -n 1 --format=%ai $newrev`); //date
+$log = trim(`git log -n 1 --format=%s $newrev`); // the log
+$changed = trim(`git log -n 1 --format=%b --name-only -p $newrev`); // the filenames
if (isset($git_tracker_debug) && $git_tracker_debug == 1) {
-$file=fopen("/tmp/debug.000","r+");
+ $file=fopen("/tmp/debug.post","a+");
fwrite($file,"Vars filled:\n");
- //fwrite($file,"arg : " . var_dump($argv) . " \n");
+ fwrite($file,"arg : " . print_r($argv,true) . " \n");
fwrite($file,"rev : " . $newrev . " \n");
fwrite($file,"username : " . $UserName . " \n");
fwrite($file,"date : " . $date . " \n");
fwrite($file,"log : " . $log . " \n");
fwrite($file,"changed : " . $changed . " \n");
-fclose($file);
+ fclose($file);
}
$changed = explode("\n", $changed);
$prev = 1;
}
while ( (!$exit) && ($actrev != 0 ) ) {
-// $changed2 = trim(`svnlook changed -r $actrev $repository | sed 's/[A-Z]* //'`);
$changed2 = trim(`git log -n 1 --format=%b --name-only -p $newrev`);
$changed2 = explode("\n", $changed2);
if ( in_array($onefile,$changed2) ) {
}
$files[] = array(
- //'name' => $repository . "/" . $onefile,
- 'name' => $hook_path . "/" . $onefile,
- //'previous' => $prev,
+ 'name' => $onefile,
'previous' => $oldrev,
- //'actual' => $revision
'actual' => $newrev
);
}
$SubmitUrl = util_make_url('/plugins/scmhook/committracker/newcommitgit.php');
-$tasks_involved= getInvolvedTasks($log);
-$artifacts_involved= getInvolvedArtifacts($log);
+$tasks_involved = getInvolvedTasks($log);
+$artifacts_involved = getInvolvedArtifacts($log);
if ((!is_array($tasks_involved) || count($tasks_involved) < 1) &&
(!is_array($artifacts_involved) || count($artifacts_involved) < 1)) {
//nothing to post
foreach ( $files as $onefile )
{
$SubmitVars[$i]["UserName"] = $UserName;
- $SubmitVars[$i]["Repository"] = $hook_path;
+ $SubmitVars[$i]["Repository"] = $repo_path;
$SubmitVars[$i]["FileName"] = $onefile['name'];
$SubmitVars[$i]["PrevVersion"] = $onefile['previous'];
$SubmitVars[$i]["ActualVersion"] = $onefile['actual'];
$SubmitVars[$i]["GitDate"] = time();
$i++;
}
+
$vars['data'] = urlencode(serialize($SubmitVars));
-//var_dump($SubmitUrl);
-//var_dump($vars['data']);
$snoopy->submit($SubmitUrl, $vars);
-?>
+
require_once $gfcommon.'mail/MailingList.class.php';
require_once $gfcommon.'mail/MailingListFactory.class.php';
- if ($this->group->usesMail()) {
+ if ($this->group->usesMail() && forge_get_config('use_ssh','scmgit')) {
$mlFactory = new MailingListFactory($this->group);
$mlArray = $mlFactory->getMailingLists();
$mlCount = count($mlArray);
return true;
}
$this->disabledMessage = _('Hook not available due to missing dependency : Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
- } else {
+ } elseif (!$this->group->usesMail()) {
$this->disabledMessage = _('Hook not available due to missing dependency : Project not using mailing-list.');
- }
- return false;
+ } elseif (!forge_get_config('use_ssh','scm_git')) {
+ $this->disabledMessage = _('Hook not available due to missing dependency : Forge not using ssh for git.');
+ }
+ return false;
+
}
function getDisabledMessage() {
*
* Copyright Daniel A. Perez <danielperez.arg@gmail.com>
* Copyright 2013, Franck Villaume - TrivialDev
- * Copyright 2013, Benoit Debaenst - TrivialDev
+ * Copyright 2014, Benoit Debaenst - TrivialDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
$i++;
}
}
-var_dump($SubmittedVar);
-echo "inside newcommit ";
+
/**
* Checks if the commit it's possible and parse arguments
* Checks if repository, group and user_name are right.
$repos_path.='/';
}
$repo_root = substr($Repository,0,strrpos($Repository,"/") + 1); //we get the directory of the repository root (with trailing slash)
-
if(fileinode($repos_path) == fileinode($repo_root)) { // since the $repos_path is usually $sys_gitroot, and that one is a symlink, we check that the inode is the same for both
$GroupName = substr($Repository, strrpos($Repository,"/") + 1);
$Config['FileName'] = substr($Config['FileName'],strlen($Repository)); //get only the filename relative to the repo
} else {
- $GroupName = $Repository;
+ $GroupName = trim(str_replace($repos_path,'',$repo_root),"/");
$Config['FileName'] = $Config['FileName'];
}
return $return;
}
+
+
if (isset($Configs) && is_array($Configs)) {
foreach ($Configs as $Config) {
$Result = parseConfig($Config);