* Copyright 2005, Guillaume Smet <guillaume-gforge@smet.org>
* Copyright 2011, Franck Villaume - Capgemini
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013, Benoit Debaenst - TrivialDev
+ * Copyright 2013-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
$this->unixname = "committracker";
$this->needcopy = 0;
$this->command = '/usr/bin/php -d include_path='.ini_get('include_path').' '.forge_get_config('plugins_path').'/scmhook/library/'.
- $this->label.'/hooks/'.$this->unixname.'/post.php "$1" "$2"';
+ $this->label.'/hooks/'.$this->unixname.'/post.php $PARAMS $SCRIPTPATH';
}
function isAvailable() {
}
/**
- * It display a table with commit related to this tracker or task_extra_detail
+ * getCommitEntries - It display a table with commit related to this tracker or task_extra_detail
*
- * @param string $Query Query to be executed to get the commit entries.
- * @param integer $group_id Group_id of the actual Group_id
+ * @param string $DBResult Result of the commit entries.
+ * @param integer $group_id Group_id of the actual Group_id
*
*/
function getCommitEntries($DBResult, $group_id) {
}
/**
- * Return an array with titles of Box to display the entries
+ * getTitleArr - Return an array with titles of Box to display the entries
*
- * @return Array The array containing the titles
+ * @param integer $group_id Group_id of the actual Group_id
+ *
+ * @return Array $title_arr The array containing the titles
*
*/
function getTitleArr($group_id) {
$title_arr=array();
-//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');
}
/**
- * Return a link to the File in gitweb
+ * getFileLink - Return a link to the Filename
*
- * @param String $GroupName is the Name of the project
- * @param String $FileName is the FileName ( with path )
- * @param Int $LatestRevision is the last revision for the file
+ * @param String $GroupName is the Name of the project
+ * @param String $FileName is the FileName ( with path )
+ * @param Int $LatestRevision is the last revision for the file
*
- * @return String The string containing a link to the File in the gitweb
+ * @return String $FileName The string containing a link to the File in the gitwe
*
*/
function getFileLink($GroupName, $FileName, $LatestRevision) {
}
/**
- * Return a link to the File in viewcvs in the specified Version
+ * getActualVersionLink - Return a link to the actual version File
*
- * @param String $GroupName is the Name of the project
- * @param String $FileName is the FileName ( with path )
- * @param String $Version the version to retrieve
+ * @param String $GroupName is the Name of the project
+ * @param String $FileName is the FileName ( with path )
+ * @param String $Version the version to retrieve
*
- * @return String The string containing a link to the File in the viewcvs
+ * @return String $Version The string containing a link to the actual version File
*
*/
function getActualVersionLink($GroupName, $FileName, $Version) {
}
/**
- * Return a link to the diff between two versions of a File in viewcvs
+ * getDiffLink - Return a link to the old versions of a File
*
- * @param String $GroupName is the Name of the project
- * @param String $FileName is the FileName ( with path )
- * @param String $PrevVersion First version to retrieve
- * @param String $ActualVersion Second version to retrieve
+ * @param String $GroupName is the Name of the project
+ * @param String $FileName is the FileName ( with path )
+ * @param String $PrevVersion First version to retrieve
+ * @param String $ActualVersion Second version to retrieve
*
- * @return String The string containing a link to the File in the cvsweb
+ * @return String $PrevVersion The string containing the old version File
*
*/
function getDiffLink($GroupName, $FileName, $PrevVersion, $ActualVersion) {
/**
* Copyright 2011, Franck Villaume - Capgemini
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013, Benoit Debaenst - Trivialdev
+ * Copyright 2013-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
if (count($newHooksPostReceive)) {
// prepare the post-receive
$file = fopen("/tmp/post-receive-$unixname.tmp", "w");
- fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/post-receive/head'));
- $string = '';
- foreach($newHooksPostReceive as $newHookPostReceive) {
- $string .= $newHookPostReceive->getHookCmd()."\n";
- }
- $string .= "\n";
- fwrite($file, $string);
- fclose($file);
- copy('/tmp/post-receive-'.$unixname.'.tmp', $gitdir_root.'/hooks/post-receive');
- chmod($gitdir_root.'/hooks/post-receive', 0755);
- unlink('/tmp/post-receive-'.$unixname.'.tmp');
-/*
- copy($gitdir_root.'/config',$gitdir_root.'/config.backup');
- $file = fopen("$gitdir_root/config", "a");
- $string = "[hooks]\n";
- $string .= "\tmailinglist = ".$unixname.'-commits@'.forge_get_config('lists_host')."\n";
- $string .= "\temailprefix = \"[".$unixname.'-commits] "'."\n";
+ fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/post-receive/head'));
+ $string = '';
+
+ foreach($newHooksPostReceive as $newHookPostReceive) {
+ $string .= $newHookPostReceive->getHookCmd()."\n";
+ }
+
+ $string .= "\n";
fwrite($file, $string);
- fclose($file);
+ fclose($file);
- copy(dirname(__FILE__).'/../hooks/postreceiveemail/postreceiveemail', $gitdir_root.'/hooks/post-receive');
+ copy('/tmp/post-receive-'.$unixname.'.tmp', $gitdir_root.'/hooks/post-receive');
chmod($gitdir_root.'/hooks/post-receive', 0755);
-*/
+ unlink('/tmp/post-receive-'.$unixname.'.tmp');
+
+ if (! preg_grep("/mailinglist/",file($gitdir_root.'/config'))) {
+ copy($gitdir_root.'/config',$gitdir_root.'/config.backup');
+ $file = fopen("$gitdir_root/config", "a");
+ $string = "[hooks]\n";
+ $string .= "\tmailinglist = ".$unixname.'-commits@'.forge_get_config('lists_host')."\n";
+ $string .= "\temailprefix = \"[".$unixname.'-commits] "'."\n";
+ fwrite($file, $string);
+ fclose($file);
+ }
+
} else {
@unlink($gitdir_root.'/hooks/post-receive');
}
* 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.
require $gfplugins.'scmhook/library/scmgit/hooks/committracker/Snoopy.class.php';
/**
- * It returns the usage and exit program
+ * usage - It returns the usage and exit program
*
- * @param string $argv
+ * @param string $prog
*
*/
-function usage( $argv ) {
- echo "Usage: $argv[0] <Repository> <Revision> \n";
- exit(0);
+function usage( $prog ) {
+ echo "Usage: $prog <oldrev> <newrev> <refname> <repo_path> \n";
+ echo "You must control parameters! \n";
+ exit(1);
}
/**
- * It returns a list of involved artifacts.
+ * getInvolvedArtifacts - It returns a list of involved artifacts.
* An artifact is identified if [#(NUMBER)] if found.
*
- * @param string $Log Log message to be parsed.
+ * @param string $Log Log message to be parsed.
*
- * @return boot Returns true if check passed.
+ * @return string $Result Returns artifact.
*/
function getInvolvedArtifacts($Log)
{
}
/**
- * It returns a list of involved artifacts.
- * An artifact is identified if [T(NUMBER)] is found.
+ * getInvolvedTasks - It returns a list of involved tasks.
+ * A task is identified if [T(NUMBER)] is found.
*
- * @param string $Log Log message to be parsed.
+ * @param string $Log Log message to be parsed.
*
- * @return boot Returns true if check passed.
+ * @return string $Result Returns task.
*/
function getInvolvedTasks($Log)
{
}
/**
- * Parse input and get the Log message.
+ * getLog - Parse input and get the Log message.
*
- * @param string $Input Input from stdin.
+ * @param string $Input Input from stdin.
*
- * @return array Array of lines of Log Message.
+ * @return array Array of lines of Log Message.
*/
function getLog($Input)
{
$files = array();
if (count($argv) != 5) {
- echo <<<USAGE
-Usage: $0 <repository> <revision>
- This program should be automatically called by SVN
-USAGE;
-
- exit;
+ usage("post.php");
}
$oldrev = $argv[1];
chdir($repo_path);
$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
+$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`);
if (isset($git_tracker_debug) && $git_tracker_debug == 1) {
$file=fopen("/tmp/debug.post","a+");
$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
$vars['data'] = urlencode(serialize($SubmitVars));
$snoopy->submit($SubmitUrl, $vars);
-?>
\ No newline at end of file
+?>
$this->label = "scmgit";
$this->unixname = "postreceiveemail";
$this->needcopy = 0;
- $this->command = '/bin/sh '.forge_get_config('plugins_path').'/scmhook/library/'.$this->label.'/hooks/'.$this->unixname.'/postreceiveemail $*';
+ $this->command = '/bin/sh '.forge_get_config('plugins_path').'/scmhook/library/'.$this->label.'/hooks/'.$this->unixname.'/postreceiveemail <<eoc '."\n".'$PARAMS'."\n".'eoc';
}
function isAvailable() {
$this->disabledMessage = _('Hook not available due to missing dependency: Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
} elseif (!$this->group->usesMail()) {
$this->disabledMessage = _('Hook not available due to missing dependency: Project not using mailing-list.');
- } 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;
-
+ } 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() {
#!/bin/sh
+read PARAMS
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`