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, master has been updated
via f4be58c1f9e456b87a395b17149ebb87baa8459d (commit)
via a074d3f8e3b79201b287eb6c043624eb7aac5cb6 (commit)
via 438b26c4d378aeb7090e6d8d81e1b22efab4ae75 (commit)
via 7673df956091958ca32f6300e7dd2ec8e8929642 (commit)
from 66519e3324d1c706c28f55cc0b25cd8d7875f5da (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 -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=f4be58c1f9e456b87a395b17149ebb87baa8459d
commit f4be58c1f9e456b87a395b17149ebb87baa8459d
Author: Franck Villaume <[email protected]>
Date: Mon Jul 31 15:09:28 2017 +0000
Start merge Patch [#700] CVS for Scmhook
diff --git a/src/CHANGES b/src/CHANGES
index 3cd9126..34c1886 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -22,6 +22,7 @@ FusionForge 6.X:
* Plugin Blocks: support Markdown syntax. (TrivialDev)
* Plugin GlobalActivity: forge-wide aggregation for project activities (Roland
Mas)
* Plugin Mediawiki: support activity for public project (TrivialDev)
+* Plugin Scmhook: add CVS commitTracker hook [#700] (Philipp Keidel &
TrivialDev)
* Projects Page: add paging system in full_list and tag_cloud subpages
(TrivialDev)
* SearchEngine: support only FTI queries (TrivialDev)
* Search: index project tags and use them for search (Roland Mas)
diff --git a/src/plugins/scmhook/common/scmhookPlugin.class.php
b/src/plugins/scmhook/common/scmhookPlugin.class.php
index 5864342..e746db2 100644
--- a/src/plugins/scmhook/common/scmhookPlugin.class.php
+++ b/src/plugins/scmhook/common/scmhookPlugin.class.php
@@ -6,6 +6,7 @@
* Copyright 2012, Benoit Debaenst - TrivialDev
* Copyright 2012-2014,2017, Franck Villaume - TrivialDev
* Copyright 2014, Sylvain Beucler - Inria
+ * Copyright 2014, Philipp Keidel - EDAG Engineering AG
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
@@ -213,6 +214,10 @@ project independently.");
$this->displayScmGitHook($hooksAvailable, $hooksEnabled);
break;
}
+ case "scmcvs": {
+
$this->displayScmCVSHook($hooksAvailable, $hooksEnabled);
+ break;
+ }
default: {
echo $HTML->warning_msg(_('SCM Type not
supported yet by scmhook'));
break;
@@ -423,6 +428,7 @@ project independently.");
echo $HTML->listTableBottom();
}
}
+
function displayScmGitHook($hooksAvailable, $hooksEnabled) {
global $HTML;
$hooksPostReceive = array();
@@ -472,6 +478,66 @@ project independently.");
echo $HTML->listTableBottom();
}
}
+
+ function displayScmCVSHook($hooksAvailable, $statusDeploy,
$hooksEnabled) {
+ global $HTML;
+ $hooksPostCommit = array();
+ foreach ($hooksAvailable as $hook) {
+ switch ($hook->getHookType()) {
+ case "post-commit": {
+ $hooksPostCommit[] = $hook;
+ break;
+ }
+ default: {
+ //byebye hook.... we do not know you...
+ break;
+ }
+ }
+ }
+ if (count($hooksPostCommit)) {
+ echo html_e('h3', array(), _('post-commit Hooks'));
+ $tabletop = array('', _('Hook Name'), _('Description'));
+ $classth = array('unsortable', '', '');
+ echo $HTML->listTableTop($tabletop, false,
'sortable_scmhook_postcommit', 'sortable', $classth);
+ foreach ($hooksPostCommit as $hookPostCommit) {
+ $isdisabled = 0;
+ if (! empty($hookPostCommit->onlyGlobalAdmin)
&& ! Permission::isGlobalAdmin()) {
+ echo '<tr style="display: none;" ><td>';
+ } else {
+ echo '<tr><td>';
+ }
+ echo '<input type="checkbox" ';
+ echo
'name="'.$hookPostCommit->getLabel().'_'.$hookPostCommit->getClassname().'" ';
+ if (in_array($hookPostCommit->getClassname(),
$hooksEnabled))
+ echo ' checked="checked"';
+
+ if ($statusDeploy) {
+ $isdisabled = 1;
+ echo ' disabled="disabled"';
+ }
+
+ if (!$isdisabled &&
!$hookPostCommit->isAvailable())
+ echo ' disabled="disabled"';
+
+ echo ' />';
+ if (in_array($hookPostCommit->getClassname(),
$hooksEnabled) && $statusDeploy) {
+ echo '<input type="hidden" ';
+ echo
'name="'.$hookPostCommit->getLabel().'_'.$hookPostCommit->getClassname().'" ';
+ echo 'value="on" />';
+ }
+ echo '</td><td';
+ if (!$hookPostCommit->isAvailable())
+ echo ' class="tabtitle-w"
title="'.$hookPostCommit->getDisabledMessage().'"';
+
+ echo ' >';
+ echo $hookPostCommit->getName();
+ echo '</td><td>';
+ echo $hookPostCommit->getDescription();
+ echo '</td></tr>';
+ }
+ echo $HTML->listTableBottom();
+ }
+ }
}
// Local Variables:
diff --git a/src/plugins/scmhook/cronjobs/updateScmRepo.php
b/src/plugins/scmhook/cronjobs/updateScmRepo.php
index ccdda46..29b62fd 100755
--- a/src/plugins/scmhook/cronjobs/updateScmRepo.php
+++ b/src/plugins/scmhook/cronjobs/updateScmRepo.php
@@ -2,8 +2,9 @@
<?php
/**
* Copyright 2011, Franck Villaume - Capgemini
- * Copyright 2012-2013, Franck Villaume - TrivialDev
+ * Copyright 2012-2013,2017, Franck Villaume - TrivialDev
* Copyright 2013, Benoit Debaenst - TrivialDev
+ * Copyright 2014, Philipp Keidel - EDAG Engineering AG
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
@@ -133,6 +134,23 @@ function install_hooks($params) {
}
break;
+ case 'scmcvs': {
+ cron_debug("INFO start updating hooks for project
".$group->getUnixName());
+ require_once
$gfplugins.'scmhook/library/'.$scmtype.'/cronjobs/updateScmRepo.php';
+ $scmcvscronjob = new ScmCvsUpdateScmRepo();
+ $params = array();
+ $params['group_id'] = $group_id;
+ $params['hooksString'] = $row['hooks'];
+ $params['scm_root'] = forge_get_config('repos_path',
'scmcvs') . '/' . $group->getUnixName();
+ if ($scmcvscronjob->updateScmRepo($params)) {
+ $res = db_query_params('UPDATE plugin_scmhook
set need_update = $1 where id_group = $2', array(0, $group_id));
+ if (!$res) {
+ $returnvalue = false;
+ }
+ }
+ break;
+ }
+
default:
cron_debug("WARNING No scm plugin found for this
project ".$group->getUnixName()." or no cronjobs for this type");
$returnvalue = false;
diff --git
a/src/plugins/scmhook/db/20170731-create_scmhook_scmcvs_committracker.sql
b/src/plugins/scmhook/db/20170731-create_scmhook_scmcvs_committracker.sql
new file mode 100644
index 0000000..02ed87c
--- /dev/null
+++ b/src/plugins/scmhook/db/20170731-create_scmhook_scmcvs_committracker.sql
@@ -0,0 +1,17 @@
+CREATE TABLE plugin_scmhook_scmcvs_committracker_data_artifact (
+ id serial PRIMARY KEY,
+ kind integer DEFAULT '0' NOT NULL,
+ group_artifact_id integer,
+ project_task_id integer
+);
+
+CREATE TABLE plugin_scmhook_scmcvs_committracker_data_master (
+ id serial PRIMARY KEY,
+ holder_id integer NOT NULL,
+ cvs_date integer NOT NULL,
+ log_text text DEFAULT '',
+ file text DEFAULT '' NOT NULL,
+ prev_version text DEFAULT '',
+ actual_version text DEFAULT '',
+ author text DEFAULT '' NOT NULL
+);
diff --git a/src/plugins/scmhook/library/scmcvs/commitTracker.class.php
b/src/plugins/scmhook/library/scmcvs/commitTracker.class.php
new file mode 100644
index 0000000..eed93e0
--- /dev/null
+++ b/src/plugins/scmhook/library/scmcvs/commitTracker.class.php
@@ -0,0 +1,174 @@
+<?php
+/**
+ * scmhook commitTracker Plugin Class
+ * Copyright 2014, Philipp Keidel - EDAG Engineering AG
+ * Copyright 2017, Franck Villaume - TrivialDev
+ *
+ * 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.
+ */
+
+global $gfplugins;
+require_once $gfplugins.'scmhook/common/scmhook.class.php';
+
+class CVSCommitTracker extends scmhook {
+ var $group;
+ var $disabledMessage;
+
+ function __construct() {
+ $this->group = $GLOBALS['group'];
+ $this->name = "Post Commit";
+ $this->description = _('Every commit is pushed into related
tracker or task.');
+ $this->classname = "commitTracker";
+ $this->hooktype = "post-commit";
+ $this->label = "scmcvs";
+ $this->unixname = "committracker";
+ $this->needcopy = 0;
+ // $filepath = forge_get_config('plugins_path') .
'/scmhook/library/' . $this->label . '/hooks/' . $this->unixname . '/post.php';
+ // $this->command = '/usr/bin/php ' . $filepath . ' "$1" "$2"';
+ $filepath = forge_get_config('plugins_path') .
'/scmhook/library/' . $this->label . '/hooks/cvs_wrapper.php';
+ $this->command = 'ALL /usr/bin/php '.$filepath.'
'.$this->hooktype.' progress %{sVv} $USER';
+ }
+
+ function isAvailable() {
+ if ($this->group->usesTracker()) {
+ return true;
+ }
+ $this->disabledMessage = _('Hook not available due to missing
dependency: Project not using tracker.');
+ $this->description = "[".$this->disabledMessage."]
".$this->description;
+ return false;
+ }
+
+ function getDisabledMessage() {
+ return $this->disabledMessage;
+ }
+
+ function artifact_extra_detail($params) {
+ $DBResult = db_query_params('SELECT * FROM
plugin_scmhook_scmcvs_committracker_data_master dm,
plugin_scmhook_scmcvs_committracker_data_artifact da
+ WHERE da.group_artifact_id = $1 AND
dm.holder_id = da.id ORDER BY cvs_date desc', array($params['artifact_id']));
+ if (!$DBResult) {
+ echo '<p class="error_msg">'._('Unable to retrieve
data').'</p>';
+ } else {
+ $this->getCommitEntries($DBResult, $params['group_id']);
+ }
+ }
+
+ function task_extra_detail($params) {
+ $DBResult = db_query_params ('SELECT * FROM
plugin_scmhook_scmcvs_committracker_data_master dm,
plugin_scmhook_scmcvs_committracker_data_artifact da
+ WHERE da.project_task_id = $1 AND
dm.holder_id = da.id ORDER BY cvs_date desc', array($params['task_id']));
+ if (!$DBResult) {
+ echo '<p class="error_msg">'._('Unable to retrieve
data').'</p>';
+ } else {
+ $this->getCommitEntries($DBResult, $params['group_id']);
+ }
+ }
+
+ /**
+ * 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
+ *
+ */
+ function getCommitEntries($DBResult, $group_id) {
+ global $HTML;
+ $group = group_get_object($group_id);
+ $Rows= db_numrows($DBResult);
+
+ if ($Rows > 0) {
+ echo '<tr><td>';
+ echo '<h2>'._('Related CVS commits').'</h2>';
+
+ $title_arr = $this->getTitleArr();
+ echo $HTML->listTableTop($title_arr);
+
+ for ($i=0; $i<$Rows; $i++) {
+ $Row = db_fetch_array($DBResult);
+ echo '<tr ' . $HTML->boxGetAltRowStyle($i) .'>'.
+ '<td>' .
$this->getFileLink($group->getUnixName(), $Row['file'],$Row['actual_version'])
. '</td>'.
+ '<td>' . date(_('Y-m-d'),
$Row['cvs_date']).'</td>'.
+ '<td>' .
$this->getDiffLink($group->getUnixName(), $Row['file'], $Row['prev_version'],
$Row['actual_version']) . '</td>'.
+ '<td>' .
$this->getActualVersionLink($group->getUnixName(), $Row['file'],
$Row['actual_version']) . '</td>
+ <td>' .
htmlspecialchars($Row['log_text']).'</td>
+ <td>' .
util_make_link_u($Row['author'],
user_get_object_by_name($Row['author'])->getId(), $Row['author']) . '</td>
+ </tr>';
+ }
+ echo $HTML->listTableBottom();
+ echo '</td></tr>';
+ }
+ }
+
+ /**
+ * Return an array with titles of Box to display the entries
+ *
+ * @return Array The array containing the titles
+ *
+ */
+ function getTitleArr() {
+ $title_arr = array();
+ $title_arr[] = _('File Name');
+ $title_arr[] = _('Date');
+ $title_arr[] = _('Previous Version');
+ $title_arr[] = _('Current Version');
+ $title_arr[] = _('Log Message');
+ $title_arr[] = _('Author');
+ return $title_arr;
+ }
+
+ /**
+ * Return a link to the File in cvsweb
+ *
+ * @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
cvsweb
+ *
+ */
+ function getFileLink($GroupName, $FileName, $LatestRevision) {
+ return util_make_link ('/scm/viewvc.php/'.$FileName .
'?root='.$GroupName.'&view=log&rev=' . $LatestRevision, $FileName) ;
+ }
+
+ /**
+ * Return a link to the File in viewcvs in the specified Version
+ *
+ * @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
+ *
+ */
+ function getActualVersionLink($GroupName, $FileName, $Version) {
+ return util_make_link ('/scm/viewvc.php/'.$FileName .
'?root='.$GroupName.'&rev='.$Version, $Version);
+ }
+
+ /**
+ * Return a link to the diff between two versions of a File in viewcvs
+ *
+ * @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
+ *
+ */
+ function getDiffLink($GroupName, $FileName, $PrevVersion,
$ActualVersion) {
+ if($PrevVersion != 'NONE' && $ActualVersion != 'NONE')
+ return util_make_link ('/scm/viewvc.php/'.$FileName .
'?root='.$GroupName.'&r1='.$PrevVersion . '&r2='.$ActualVersion, _('Diff To').'
'.$PrevVersion);
+ return _('Wrong situation');
+ }
+}
diff --git a/src/plugins/scmhook/library/scmcvs/cronjobs/updateScmRepo.php
b/src/plugins/scmhook/library/scmcvs/cronjobs/updateScmRepo.php
new file mode 100644
index 0000000..847a3bf
--- /dev/null
+++ b/src/plugins/scmhook/library/scmcvs/cronjobs/updateScmRepo.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Copyright (C) 2014 Philipp Keidel - EDAG Engineering AG
+ *
+ * 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.
+ */
+
+/**
+ * you need to implement only function updateScmRepo($params)
+ * $params is an array containing :
+ * $params['group_id'] = $group_id
+ * $params['hooksString'] = list of hooks to be deploy, separator is |
+ * $params['scm_root'] = directory containing the scm repository
+ */
+
+class ScmCvsUpdateScmRepo {
+ /**
+ * updateScmRepo - update the scmrepo with the new hooks
+ *
+ * @params Array the complete array description
+ * @return boolean success or not
+ */
+ function updateScmRepo($params) {
+ $group_id = $params['group_id'];
+ $hooksString = $params['hooksString'];
+ $cvsdir_root = $params['scm_root'];
+ $group = group_get_object($group_id);
+ $scmhookPlugin = new scmhookPlugin;
+ $hooksAvailable = $scmhookPlugin->getAvailableHooks($group_id);
+ $unixname = $group->getUnixName();
+
+ if (is_dir($cvsdir_root)) {
+ @unlink($cvsdir_root.'/hooks/pre-commit');
+ @unlink($cvsdir_root.'/hooks/post-commit');
+ $hooksPostCommit = array();
+ foreach ($hooksAvailable as $hook) {
+ switch ($hook->getHookType()) {
+ case 'post-commit': {
+ $hooksPostCommit[] = $hook;
+ break;
+ }
+ default: {
+ //byebye hook.... we do not
validate you...
+ break;
+ }
+ }
+ }
+ foreach($hooksPostCommit as $hookPostCommit) {
+ if ($hookPostCommit->needCopy()) {
+ foreach($hookPostCommit->getFiles() as
$hookPostCommitFile) {
+
@unlink($cvsdir_root.'/hooks/'.basename($hookPostCommitFile));
+ }
+ }
+ }
+
+ $newHooks = explode('|', $hooksString);
+ if (count($newHooks)) {
+ $newHooksPostCommit = array();
+ foreach($newHooks as $newHook) {
+ foreach($hooksPostCommit as
$hookPostCommit) {
+ if
($hookPostCommit->getClassname() == $newHook) {
+ $newHooksPostCommit[] =
$hookPostCommit;
+ }
+ }
+ }
+ }
+ foreach($newHooksPostCommit as $newHookPostCommit) {
+ if ($newHookPostCommit->needCopy()) {
+ foreach ($newHookPostCommit->getFiles()
as $file) {
+ copy($file,
$cvsdir_root.'/hooks/'.basename($file));
+
chmod($cvsdir_root.'/hooks/'.basename($file), 0755);
+ }
+ }
+ }
+
+ $loginfo = "$cvsdir_root/CVSROOT/loginfo";
+ if (count($newHooksPostCommit)) {
+ // Befehl in /CVSROOT/loginfo eintragen
+ $content = file_get_contents($loginfo);
+ $add = '';
+ foreach($newHooksPostCommit as
$newHookPostCommit) {
+ // Wenn der Befehl noch nicht vorkommt,
dann hinzufügen
+ if(strpos($content,
$newHookPostCommit->getHookCmd()) === false) {
+ $add .=
$newHookPostCommit->getHookCmd()."\n";
+ }
+ }
+ file_put_contents($loginfo,
trim($content.$add));
+ } else {
+ // Befehl aus /CVSROOT/loginfo entfernen
+ $content = file_get_contents($loginfo);
+ file_put_contents($loginfo, "");
+ $oldLines = explode("\n", $content);
+ foreach($oldLines as $line) {
+ if(substr($line, 0, 1) == "#" ||
strpos($line, "cvs_wrapper.php") === false) {
+ file_put_contents($loginfo,
"$line\n", FILE_APPEND);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/plugins/scmhook/library/scmcvs/hooks/committracker/post.php
b/src/plugins/scmhook/library/scmcvs/hooks/committracker/post.php
new file mode 100644
index 0000000..657d18a
--- /dev/null
+++ b/src/plugins/scmhook/library/scmcvs/hooks/committracker/post.php
@@ -0,0 +1,153 @@
+#! /usr/bin/php
+<?php
+/**
+ * Copyright (C) 2014 Philipp Keidel - EDAG Engineering AG
+ *
+ * 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.
+ */
+/**
+ * This is the script called by cvs. It takes some params, and prepare some
+ * HTTP POSTs to scmhook/www/newcommitcvs.php.
+ */
+
+require_once dirname(__FILE__).'/../../../../../../common/include/env.inc.php';
+require_once $gfcommon.'include/pre.php';
+
+/**
+ * getInvolvedArtifacts - It returns a list of involved artifacts.
+ * An artifact is identified if [#(NUMBER)] if found.
+ *
+ * @param string $Log Log message to be parsed.
+ *
+ * @return string $Result Returns artifact.
+ */
+function getInvolvedArtifacts($Log) {
+ preg_match_all('/[\[]#[\d]+[\]]/', $Log, $Matches );
+ foreach($Matches as $Match) {
+ $Result = preg_replace ('/[[]#([\d]+)[]]/', '\1', $Match);
+ }
+ return $Result;
+}
+
+/**
+ * getInvolvedTasks - It returns a list of involved tasks.
+ * A task is identified if [T(NUMBER)] if found.
+ *
+ * @param string $Log Log message to be parsed.
+ *
+ * @return string $Result Returns artifact.
+ */
+function getInvolvedTasks($Log) {
+ preg_match_all('/[\[]T[\d]+[\]]/', $Log, $Matches );
+ foreach($Matches as $Match) {
+ $Result = preg_replace ('/[[]T([\d]+)[]]/', '\1', $Match);
+ }
+ return $Result;
+}
+
+$files = array();
+
+/**
+ * $argv: Array
+ * (
+ * [0] => Full local path to post.php
+ * [1] => /tmp/cvswrapper_IWRtXb
+ * [2] => repo name
+ * [3] => dir file1,1.58,1.59 file2,1.16,1.17
+ * [4] => username
+ * )
+ *
+ * $stdin: Update of /var/lib/gforge/chroot/scmrepos/cvs/progress/ADMIN
+ * In directory gforge:/var/tmp/cvs-serv16298
+ *
+ * Modified Files:
+ * admin_env
+ * Log Message:
+ * test60
+ */
+
+if (count($argv) != 5 || !file_exists($argv[1])) {
+ echo "Usage: post.php <tmpfile> <project> <params: sVv> <user> \n";
+ echo "You must control parameters! \n";
+ exit(1);
+}
+
+$tmpname = $argv[1];
+
+$stdin = file_get_contents($tmpname);
+$projectname = $argv[2];
+$username = $argv[4];
+$misc = explode(" ", $argv[3], 2); // db\/usersess\/appserver
admin_env,1.58,1.59 codecheck,1.16,1.17
+$dirpath = $misc[0];
+
+$files = explode(" ", $misc[1]);
+$allfiles = array();
+
+unlink($tmpname);
+
+echo "dirpath: $dirpath\n";
+
+foreach($files as $file) {
+ $i = explode(",", $file);
+ $allfiles[] = array(
+ 'filename' => $i[0],
+ 'oldrev' => $i[1],
+ 'newrev' => $i[2]
+ );
+}
+
+// Log Message aus der stdin String auslesen
+$logmessage = trim(substr(stristr($stdin, 'Log Message:'), 12));
+$tasks_involved = getInvolvedTasks($logmessage);
+$artifacts_involved = getInvolvedArtifacts($logmessage);
+
+if ((!is_array($tasks_involved) || count($tasks_involved) < 1) &&
+ (!is_array($artifacts_involved) || count($artifacts_involved) < 1)) {
+ //nothing to post
+ die("No artifacts nor tasks in the commit log\n");
+}
+
+$SubmitUrl = util_make_url('/plugins/scmhook/committracker/newcommitcvs.php');
+
+$SubmitVars = array();
+$i = 0;
+foreach ( $allfiles as $onefile ) {
+ $SubmitVars[$i]["UserName"] = $username;
+ $SubmitVars[$i]["Repository"] = $projectname;
+ $SubmitVars[$i]["Directory"] = $dirpath;
+ $SubmitVars[$i]["FileName"] = $onefile['filename'];
+ $SubmitVars[$i]["PrevVersion"] = $onefile['oldrev'];
+ $SubmitVars[$i]["ActualVersion"] = $onefile['newrev'];
+ $SubmitVars[$i]["Log"] = $logmessage;
+ $SubmitVars[$i]["TaskNumbers"] = $tasks_involved;
+ $SubmitVars[$i]["ArtifactNumbers"] = $artifacts_involved;
+ $SubmitVars[$i]["CVSDate"] = time();
+ $i++;
+}
+
+$vars['data'] = urlencode(serialize($SubmitVars));
+
+// Since Snoopys last modifications were made back in 2008, we don't want to
use it here.
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $SubmitUrl);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+curl_setopt($ch, CURLOPT_POST, true);
+curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
+curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+$result = curl_exec($ch);
+// $info = curl_getinfo($ch);
+curl_close($ch);
diff --git a/src/plugins/scmhook/library/scmcvs/hooks/cvs_wrapper.php
b/src/plugins/scmhook/library/scmcvs/hooks/cvs_wrapper.php
new file mode 100644
index 0000000..489ac3c
--- /dev/null
+++ b/src/plugins/scmhook/library/scmcvs/hooks/cvs_wrapper.php
@@ -0,0 +1,52 @@
+#!/usr/bin/php
+/**
+ * Copyright (C) 2014 Philipp Keidel - EDAG Engineering AG
+ *
+ * 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.
+ */
+
+<?php
+
+$script_name=$argv[1];
+
+if ( $script_name == "post-commit" ) {
+
$script_path="/usr/share/gforge/plugins/scmhook/library/scmcvs/hooks/committracker/post.php";
+} else {
+ echo "Invalid script specified: $script_name";
+ exit(1);
+}
+
+$args = '';
+for ($i=2; $i<count($argv); $i++) {
+ $args .= escapeshellarg($argv[$i]).' ';
+}
+
+$filepath = tempnam("/tmp", "cvswrapper_");
+file_put_contents($filepath, file_get_contents("php://stdin"));
+
+$command = "cd /usr/share/gforge/plugins/ && php $script_path \"$filepath\"
$args";
+$ouptut = array();
+
+$retval = execute($command, $output);
+exit($retval);
+
+
+//////////////////////////////////////////////////
+function execute($command, &$output) {
+ $retval = 0;
+ exec($command, $output, $retval);
+ return $retval;
+}
diff --git a/src/plugins/scmhook/library/scmcvs/skel/post-commit/head
b/src/plugins/scmhook/library/scmcvs/skel/post-commit/head
new file mode 100644
index 0000000..829303e
--- /dev/null
+++ b/src/plugins/scmhook/library/scmcvs/skel/post-commit/head
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+
diff --git a/src/plugins/scmhook/www/committracker/newcommitcvs.php
b/src/plugins/scmhook/www/committracker/newcommitcvs.php
new file mode 100644
index 0000000..081fc04
--- /dev/null
+++ b/src/plugins/scmhook/www/committracker/newcommitcvs.php
@@ -0,0 +1,245 @@
+<?php
+/**
+ * scmhook plugin: CVS commitemail hook
+ *
+ * Copyright 2014, Philipp Keidel - EDAG Engineering AG
+ *
+ * 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.
+ */
+
+/**
+ * This script takes some POST variables. It makes a check and it
+ * store in DB the commit info attached to the tracker or task.
+ *
+ */
+
+$SubmittedVars = unserialize(urldecode($_POST['data']));
+
+require_once dirname(__FILE__)."/../../../env.inc.php";
+require_once $gfcommon.'include/pre.php';
+
+/**
+ * Getting POST variables
+ * UserName, Repository, Path, FileName, PrevVersion, ActualVersion, Log,
+ * ArtifactNumbers and TaskNumbers
+ */
+
+$Config = array();
+$Configs = array();
+$Configs = unserialize(urldecode($_POST['data']));
+
+/*
+$data = urldecode($_POST['data']);
+$i = 0;
+if(is_array($SubmittedVars)) {
+ foreach ($SubmittedVars as $SubmittedVar) {
+ $Configs[$i] = array();
+ $Configs[$i]['UserName'] = $SubmittedVar['UserName'];
+ $Configs[$i]['Repository'] = $SubmittedVar['Repository'];
+ $Configs[$i]['FileName'] = $SubmittedVar['FileName'];
+ $Configs[$i]['PrevVersion'] = $SubmittedVar['PrevVersion'];
+ $Configs[$i]['ActualVersion'] =
$SubmittedVar['ActualVersion'];
+ $Configs[$i]['Log'] = $SubmittedVar['Log'];
+ $Configs[$i]['ArtifactNumbers'] =
$SubmittedVar['ArtifactNumbers'];
+ $Configs[$i]['CVSDate'] = $SubmittedVar['SvnDate'];
+ //$Configs[$i]['TaskNumbers'] =
$SubmittedVar['TaskNumbers'];
+ $i++;
+ }
+}
+*/
+
+/**
+ * Checks if the commit it's possible and parse arguments
+ * Checks if repository, group and user_name are right.
+ * It extract group from svnroot, and check if the plugin
+ * is availabe. It checks if the user exists.
+ *
+ * @param array $Config Config
+ *
+ * @return array Returns 'check'=true if check passed, group, group_id
+ */
+function parseConfig(&$Config) {
+ // $repos_path = forge_get_config ('repos_path', 'scmcvs') ;
+
+ $Result = array();
+ $Result['check'] = true;
+ $Repository = $Config['Repository'];
+ $UserName = $Config['UserName'];
+ $dirpath = $Config['Directory'];
+
+ // if($repos_path[strlen($repos_path)-1]!='/') {
+ // $repos_path.='/';
+ // }
+
+
+ // if(fileinode($repos_path) == fileinode($repo_root)) {
+ // $GroupName = $Repository; // substr($Repository, 0,
strpos($Repository, '/'));
+ // $Config['FileName'] = $Config['FileName'];
+ // }
+
+ // $repo_root = $repos_path.$GroupName;
+
+ $Result['group'] = group_get_object_by_name($Repository);
+ $Result['user'] = user_get_object_by_name($UserName);
+
+ if (!$Result['group'] || !is_object($Result['group']) ||
+ $Result['group']->isError() || !$Result['group']->isActive()) {
+ $Result['check'] = false;
+ $Result['error'] = "Repository/Group '$Repository' Not Found";
+ } else {
+ $Result['group_id'] = $Result['group']->getID();
+ if (!$Result['group']->usesPlugin('scmhook')) {
+ $Result['check'] = false;
+ $Result['error'] = 'Plugin not enabled for this Group';
+ }
+ }
+
+ if (!$Result['user'] || !is_object($Result['user']) ||
+ $Result['user']->isError() || !$Result['user']->isActive()) {
+ $Result['check'] = false;
+ $Result['error'] = 'Invalid User';
+ }
+ return $Result;
+}
+
+/**
+ * Add a entry in the DataBase for a Artifact associated to a commit
+ *
+ * @param array $Config Config
+ * @param string $GroupId The GroupId to insert it into
+ * @param string $Num The artifact_id
+ *
+ * @return array Returns 'check'=true if check passed, group, group_id
+ */
+function addArtifactLog($Config, $GroupId, $Num) {
+ $return = array();
+ // Abfrage des Tracker Items
+ $Result = db_query_params ('SELECT * FROM artifact,artifact_group_list
+ WHERE
artifact.group_artifact_id=artifact_group_list.group_artifact_id
+ AND artifact_group_list.group_id=$1 AND
artifact.artifact_id=$2', array ($GroupId, $Num));
+ $Rows = db_numrows($Result);
+ if ($Rows == 0) {
+ $return['Error'] = "Artifact ".$Num." Not Found.";
+ }
+
+ if ($Rows == 1) {
+ db_begin();
+ $DBRes = db_query_params ('INSERT INTO
plugin_scmhook_scmcvs_committracker_data_artifact (kind, group_artifact_id)
VALUES (0, $1)', array($Num));
+ $HolderID=
db_insertid($DBRes,'plugin_scmhook_scmcvs_committracker_data_artifact','id');
+
+ if (!$DBRes || !$HolderID) {
+ $return['Error']="Problems with Artifact $Num:
".db_error();
+ db_rollback();
+ } else {
+ $DBRes = db_query_params ('INSERT INTO
plugin_scmhook_scmcvs_committracker_data_master (holder_id, cvs_date, log_text,
file, prev_version, actual_version, author) VALUES ($1, $2, $3, $4, $5, $6,
$7)',
+ array($HolderID,
+ $Config['CVSDate'],
+ $Config['Log'],
+
$Config['Directory'].'/'.$Config['FileName'],
+ $Config['PrevVersion'],
+
$Config['ActualVersion'],
+ $Config['UserName'])) ;
+ if(!$DBRes) {
+ $return['Error']="Problems with Artifact $Num:
".db_error()."\n";
+ db_rollback();
+ } else {
+ db_commit();
+ $lastID=
db_insertid($DBRes,'plugin_scmhook_scmcvs_committracker_data_master','id');
+ }
+ }
+ }
+ if ($Rows > 1) {
+ $return['Error'] .= "Unknown problem adding Tracker: $Num.";
+ }
+ return $return;
+}
+
+/*
+ * Add a entry in the DataBase for a Tracker associated to a commit
+ *
+ * @param array $Config Config
+ * @param string $GroupId The GroupId to insert it into
+ * @param string $Num The tracker_id
+ *
+ * @return array Returns 'check'=true if check passed, group, group_id
+ */
+function addTaskLog($Config, $GroupId, $Num) {
+ $return = array();
+ $Result = db_query_params ('SELECT * FROM
project_task,project_group_list
+ WHERE
project_task.group_project_id=project_group_list.group_project_id
+ AND project_task.project_task_id=$1
+ AND project_group_list.group_id=$2',
array ($Num, $GroupId));
+ $Rows = db_numrows($Result);
+ if ($Rows == 0) {
+ $return['Error'] .= "Task:$Num Not Found.";
+ }
+ if ($Rows == 1) {
+ db_begin();
+ $DBRes = db_query_params ('INSERT INTO
plugin_scmhook_scmcvs_committracker_data_artifact (kind, project_task_id)
VALUES (1, $1)',
+ array ($Num));
+ $HolderID=
db_insertid($DBRes,'plugin_scmhook_scmsvn_committracker_data_artifact','id');
+ if (!$DBRes || !$HolderID) {
+ $return['Error']='Problems with Task $Num: '.db_error();
+ db_rollback();
+ } else {
+ $DBRes = db_query_params ('INSERT INTO
plugin_scmhook_scmcvs_committracker_data_master (holder_id, svn_date, log_text,
file, prev_version, actual_version, author) VALUES ($1, $2, $3, $4, $5, $6,
$7)',
+ array($HolderID,
+ $Config['CVSDate'],
+ $Config['Log'],
+
$Config['Directory'].'/'.$Config['FileName'],
+ $Config['PrevVersion'],
+
$Config['ActualVersion'],
+ $Config['UserName']));
+ if(!$DBRes) {
+ db_rollback();
+ } else {
+ db_commit();
+ }
+ }
+ }
+ if ($Rows > 1) {
+ $return['Error'] .= "Unknown problem adding Task:$Num.";
+ }
+ return $return;
+}
+
+if (isset($Configs) && is_array($Configs)) {
+ foreach ($Configs as $Config) {
+ $Result = parseConfig($Config);
+ if ($Result['check'] == false) {
+ exit_error('Check_error', $Result['error']);
+ }
+ // ArtifactNumbers
+ if (!is_null($Config['ArtifactNumbers'])) {
+ foreach ($Config['ArtifactNumbers'] as $Num) {
+ $AddResult = addArtifactLog($Config,
$Result['group_id'], $Num);
+ if (isset($AddResult['Error'])) {
+ exit_error('Adding
ArtifactNumber',$AddResult['Error']);
+ }
+ }
+ }
+ // TaskNumbers
+ if (!is_null($Config['TaskNumbers'])) {
+ foreach ($Config['TaskNumbers'] as $Num) {
+ $AddResult = addTaskLog($Config,
$Result['group_id'], $Num);
+ if (isset($AddResult['Error'])) {
+ exit_error('Adding
TaskNumber',$AddResult['Error']);
+ }
+ }
+ }
+ }
+}
+
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=a074d3f8e3b79201b287eb6c043624eb7aac5cb6
commit a074d3f8e3b79201b287eb6c043624eb7aac5cb6
Author: Franck Villaume <[email protected]>
Date: Mon Jul 31 15:05:28 2017 +0000
use util_display_user
diff --git a/src/plugins/scmhook/library/scmgit/commitTracker.class.php
b/src/plugins/scmhook/library/scmgit/commitTracker.class.php
index d52ceb5..0b1066b 100644
--- a/src/plugins/scmhook/library/scmgit/commitTracker.class.php
+++ b/src/plugins/scmhook/library/scmgit/commitTracker.class.php
@@ -121,7 +121,8 @@ class GitCommitTracker extends scmhook {
$cells[][] =
$this->getDiffLink($group->getUnixName(), $Row['file'], $Row['prev_version'],
$Row['actual_version']);
$cells[][] =
$this->getActualVersionLink($group->getUnixName(), $Row['file'],
$Row['actual_version']);
$cells[][] = htmlspecialchars($Row['log_text']);
- $cells[][] = util_make_link_u($Row['author'],
user_get_object_by_name($Row['author'])->getId(), $Row['author']);
+ $commituser =
user_get_object_by_name($Row['author']);
+ $cells[][] =
util_display_user($commituser->getUnixName(), $commituser->getId(),
$commituser->getRealname());
$return .= $HTML->multiTableRow(array(),
$cells);
}
$return .= $HTML->listTableBottom();
diff --git a/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
b/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
index 98f843b..0bbd6ab 100644
--- a/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
+++ b/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
@@ -116,7 +116,8 @@ class SvnCommitTracker extends scmhook {
$cells[][] =
$this->getDiffLink($group->getUnixName(), $Row['file'], $Row['prev_version'],
$Row['actual_version']);
$cells[][] =
$this->getActualVersionLink($group->getUnixName(), $Row['file'],
$Row['actual_version']);
$cells[][] = htmlspecialchars($Row['log_text']);
- $cells[][] = util_make_link_u($Row['author'],
user_get_object_by_name($Row['author'])->getId(), $Row['author']);
+ $commituser =
user_get_object_by_name($Row['author']);
+ $cells[][] =
util_display_user($commituser->getUnixName(), $commituser->getId(),
$commituser->getRealname());
$return .= $HTML->multiTableRow(array(),
$cells);
}
$return .= $HTML->listTableBottom();
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=438b26c4d378aeb7090e6d8d81e1b22efab4ae75
commit 438b26c4d378aeb7090e6d8d81e1b22efab4ae75
Author: Franck Villaume <[email protected]>
Date: Mon Jul 31 15:04:59 2017 +0000
coding style
diff --git a/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
b/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
index b9f2ffb..b2ea41e 100755
--- a/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
+++ b/src/plugins/scmhook/library/scmgit/hooks/committracker/post.php
@@ -182,8 +182,7 @@ if ((!is_array($tasks_involved) || count($tasks_involved) <
1) &&
}
$i = 0;
-foreach ( $files as $onefile )
-{
+foreach ($files as $onefile) {
$SubmitVars[$i]["UserName"] = $UserName;
$SubmitVars[$i]["Email"] = $email;
$SubmitVars[$i]["Repository"] = $repo_path;
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=7673df956091958ca32f6300e7dd2ec8e8929642
commit 7673df956091958ca32f6300e7dd2ec8e8929642
Author: Franck Villaume <[email protected]>
Date: Mon Jul 31 15:04:26 2017 +0000
remove duplicated lines
diff --git a/src/plugins/scmhook/library/scmsvn/hooks/committracker/post.php
b/src/plugins/scmhook/library/scmsvn/hooks/committracker/post.php
index 3df36df..460a2ab 100755
--- a/src/plugins/scmhook/library/scmsvn/hooks/committracker/post.php
+++ b/src/plugins/scmhook/library/scmsvn/hooks/committracker/post.php
@@ -151,7 +151,7 @@ foreach ($changed as $onefile) {
$SubmitUrl = util_make_url('/plugins/scmhook/committracker/newcommit.php');
$i = 0;
-foreach ( $files as $onefile ) {
+foreach ($files as $onefile) {
$SubmitVars[$i]['UserName'] = $UserName;
$SubmitVars[$i]['Repository'] = $repository;
$SubmitVars[$i]['FileName'] = $onefile['name'];
@@ -169,8 +169,6 @@ $vars['data'] = urlencode(serialize($SubmitVars));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $SubmitUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
-curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
-----------------------------------------------------------------------
Summary of changes:
src/CHANGES | 1 +
src/plugins/scmhook/common/scmhookPlugin.class.php | 66 ++++++++
src/plugins/scmhook/cronjobs/updateScmRepo.php | 20 ++-
...170731-create_scmhook_scmcvs_committracker.sql} | 7 +-
.../scmhook/library/scmcvs/commitTracker.class.php | 174 +++++++++++++++++++++
.../library/scmcvs/cronjobs/updateScmRepo.php | 116 ++++++++++++++
.../library/scmcvs/hooks/committracker/post.php | 153 ++++++++++++++++++
.../scmhook/library/scmcvs/hooks/cvs_wrapper.php} | 48 +++---
.../scmhook/library/scmcvs/skel/post-commit/head | 3 +
.../scmhook/library/scmgit/commitTracker.class.php | 3 +-
.../library/scmgit/hooks/committracker/post.php | 3 +-
.../scmhook/library/scmsvn/commitTracker.class.php | 3 +-
.../library/scmsvn/hooks/committracker/post.php | 4 +-
.../{newcommit.php => newcommitcvs.php} | 146 ++++++++---------
14 files changed, 632 insertions(+), 115 deletions(-)
copy src/plugins/scmhook/db/{20130702-create_scmhook_git_committracker.sql =>
20170731-create_scmhook_scmcvs_committracker.sql} (75%)
create mode 100644 src/plugins/scmhook/library/scmcvs/commitTracker.class.php
create mode 100644
src/plugins/scmhook/library/scmcvs/cronjobs/updateScmRepo.php
create mode 100644
src/plugins/scmhook/library/scmcvs/hooks/committracker/post.php
copy src/{common/docman/engine/parser_pdf.php =>
plugins/scmhook/library/scmcvs/hooks/cvs_wrapper.php} (50%)
mode change 100755 => 100644
create mode 100644 src/plugins/scmhook/library/scmcvs/skel/post-commit/head
copy src/plugins/scmhook/www/committracker/{newcommit.php => newcommitcvs.php}
(64%)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits