src/plugins/scmhook/cronjobs/updateScmRepo.php -text
src/plugins/scmhook/db/scmhook-init.sql -text
src/plugins/scmhook/etc/scmhook.ini -text
+src/plugins/scmhook/library/scmhg/commitEmail.class.php -text
+src/plugins/scmhook/library/scmhg/cronjobs/updateScmRepo.php -text
src/plugins/scmhook/library/scmsvn/checkLog.class.php -text
src/plugins/scmhook/library/scmsvn/checkMimetype.class.php -text
src/plugins/scmhook/library/scmsvn/commitEmail.class.php -text
FusionForge-5.3:
* Widget: MyArtifacts Enhancement : add monitored artifacts (TrivialDev)
* Trackers: Attachements moved to filesystem to allow larger attachments & reduce DB size (Alcatel-Lucent)
+* Docman: Files moves to filesystem using the Storage generic class (TrivialDev)
* Users: notify admins when user has validated his account (TrivialDev)
* Allow project to disable the Project Activity (Alcatel-Lucent)
* User: account ssh key management: rewrite backend, add more informations such as
fingerprint, deploy flag, easy delete (TrivialDev)
+* Docman: Directory monitoring (TrivialDev)
+
Plugins:
* headermenu: new plugin to add links in login/logout menu link (TrivialDev)
* scmgit: add browsing capability for user personal repository (TrivialDev)
* scmgit: basic activity support (TrivialDev).
* scmhg: merge patch from Denise Patzker: add http support, online browse, stats (TrivialDev)
-* Docman: Files moves to filesystem using the Storage generic class (TrivialDev)
* webanalytics: new plugin to add support for piwik or google analytics tool (TrivialDev)
* scmhook: Support added for pre-revprop-changehooks to change properties (Alcatel-Lucent)
+* scmhook: Add commitEmail support for scmhg plugin (TrivialDev)
FusionForge-5.2:
* Docman: inject zip as a tree (Capgemini)
* scmhookPlugin Class
* Copyright 2011, Franck Villaume - Capgemini
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, 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
*/
class scmhookPlugin extends Plugin {
- function scmhookPlugin () {
- $this->Plugin() ;
- $this->name = "scmhook" ;
- $this->text = "Scmhook" ; // To show in the tabs, use...
+ function __construct() {
+ $this->Plugin();
+ $this->name = "scmhook";
+ $this->text = "Scmhook"; // To show in the tabs, use...
$this->_addHook('groupmenu'); // To put into the project tabs
$this->_addHook('groupisactivecheckbox'); // The "use ..." checkbox in editgroupinfo
$this->_addHook('groupisactivecheckboxpost'); //
$scm_plugin = $params['scm_plugin'];
$group = &group_get_object($group_id);
if ($group->usesPlugin($this->name) && $scm_plugin) {
- $this->displayScmHook($group_id);
+ $this->displayScmHook($group_id, $scm_plugin);
}
break;
}
$hooksString = '';
foreach($params as $key => $value) {
if ($key == strstr($key, 'scm')) {
- $hookname = preg_replace('/scm[a-z][a-z][a-z]_/','',$key);
+ $hookname = preg_replace('/scm[a-z][a-z]+_/','',$key);
if ($key != $hookname) { //handle the case of scm_enable_anonymous
if (strlen($hooksString)) {
$hooksString .= '|'.$hookname;
return true;
}
- function displayScmHook($group_id) {
- global $HTML;
- use_javascript('/js/sortable.js');
+ function displayScmHook($group_id, $scm) {
$hooksAvailable = $this->getAvailableHooks($group_id);
$statusDeploy = $this->getStatusDeploy($group_id);
$hooksEnabled = $this->getEnabledHooks($group_id);
echo '<p class="warning">'._('Hooks management update process waiting ...').'</p>';
echo '<h2>'._('Enable Repository Hooks').'</h2>';
- $hooksPreCommit = array();
- $hooksPreRevPropChange = array();
- $hooksPostCommit = array();
- foreach ($hooksAvailable as $hook) {
- switch ($hook->getHookType()) {
- case "pre-commit": {
- $hooksPreCommit[] = $hook;
- break;
- }
- case "pre-revprop-change": {
- $hooksPreRevPropChange[] = $hook;
- break;
- }
- case "post-commit": {
- $hooksPostCommit[] = $hook;
- break;
- }
- default: {
- echo 'ici';
- //byebye hook.... we do not validate you...
- break;
- }
- }
- }
- if (count($hooksPreCommit)) {
- echo '<h3>'._('pre-commit Hooks').'</h3>';
- $tabletop = array('', _('Hook Name'), _('Description'));
- $classth = array('unsortable', '', '');
- echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
- foreach ($hooksPreCommit as $hookPreCommit) {
- if (! empty($hookPreCommit->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
- echo '<tr style="display: none;" ><td>';
- }
- else {
- echo '<tr><td>';
- }
- echo '<input type="checkbox" ';
- echo 'name="'.$hookPreCommit->getLabel().'_'.$hookPreCommit->getClassname().'" ';
- if (in_array($hookPreCommit->getClassname(), $hooksEnabled))
- echo ' checked="checked"';
-
- if ($statusDeploy)
- echo ' disabled="disabled"';
-
- echo ' />';
- echo '</td><td>';
- echo $hookPreCommit->getName();
- echo '</td><td>';
- echo $hookPreCommit->getDescription();
- echo '</td></tr>';
- }
- echo $HTML->listTableBottom();
- }
- if (count($hooksPreRevPropChange)) {
- echo '<h3>'._('pre-revprop-change Hooks').'</h3>';
- $tabletop = array('', _('Hook Name'), _('Description'));
- $classth = array('unsortable', '', '');
- echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
- foreach ($hooksPreRevPropChange as $hook) {
- if (! empty($hook->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
- echo '<tr style="display: none;" ><td>';
- }
- else {
- echo '<tr><td>';
- }
- echo '<input type="checkbox" ';
- echo 'name="'.$hook->getLabel().'_'.$hook->getClassname().'" ';
- if (in_array($hook->getClassname(), $hooksEnabled))
- echo ' checked="checked"';
-
- if ($statusDeploy)
- echo ' disabled="disabled"';
-
- echo ' />';
- echo '</td><td>';
- echo $hook->getName();
- echo '</td><td>';
- echo $hook->getDescription();
- echo '</td></tr>';
+ switch ($scm) {
+ case "scmsvn": {
+ $this->displayScmSvnHook($hooksAvailable, $statusDeploy, $hooksEnabled);
+ break;
}
- echo $HTML->listTableBottom();
- }
- if (count($hooksPostCommit)) {
- echo '<h3>'._('post-commit Hooks').'</h3>';
- $tabletop = array('', _('Hook Name'), _('Description'));
- $classth = array('unsortable', '', '');
- echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_postcommit', 'sortable', $classth);
- foreach ($hooksPostCommit as $hookPostCommit) {
- 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)
- echo ' disabled="disabled"';
-
- echo ' />';
- echo '</td><td>';
- echo $hookPostCommit->getName();
- echo '</td><td>';
- echo $hookPostCommit->getDescription();
- echo '</td></tr>';
+ case "scmhg": {
+ $this->displayScmHgHook($hooksAvailable, $statusDeploy, $hooksEnabled);
+ break;
}
- echo $HTML->listTableBottom();
}
echo '</div><p />';
} else {
}
return true;
}
+
+ function displayScmSvnHook($hooksAvailable, $statusDeploy, $hooksEnabled) {
+ global $HTML;
+ $hooksPreCommit = array();
+ $hooksPreRevPropChange = array();
+ $hooksPostCommit = array();
+ foreach ($hooksAvailable as $hook) {
+ switch ($hook->getHookType()) {
+ case "pre-commit": {
+ $hooksPreCommit[] = $hook;
+ break;
+ }
+ case "pre-revprop-change": {
+ $hooksPreRevPropChange[] = $hook;
+ break;
+ }
+ case "post-commit": {
+ $hooksPostCommit[] = $hook;
+ break;
+ }
+ default: {
+ //byebye hook.... we do not know you...
+ break;
+ }
+ }
+ }
+ if (count($hooksPreCommit)) {
+ echo '<h3>'._('pre-commit Hooks').'</h3>';
+ $tabletop = array('', _('Hook Name'), _('Description'));
+ $classth = array('unsortable', '', '');
+ echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
+ foreach ($hooksPreCommit as $hookPreCommit) {
+ if (! empty($hookPreCommit->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
+ echo '<tr style="display: none;" ><td>';
+ }
+ else {
+ echo '<tr><td>';
+ }
+ echo '<input type="checkbox" ';
+ echo 'name="'.$hookPreCommit->getLabel().'_'.$hookPreCommit->getClassname().'" ';
+ if (in_array($hookPreCommit->getClassname(), $hooksEnabled))
+ echo ' checked="checked"';
+
+ if ($statusDeploy)
+ echo ' disabled="disabled"';
+
+ echo ' />';
+ echo '</td><td>';
+ echo $hookPreCommit->getName();
+ echo '</td><td>';
+ echo $hookPreCommit->getDescription();
+ echo '</td></tr>';
+ }
+ echo $HTML->listTableBottom();
+ }
+ if (count($hooksPreRevPropChange)) {
+ echo '<h3>'._('pre-revprop-change Hooks').'</h3>';
+ $tabletop = array('', _('Hook Name'), _('Description'));
+ $classth = array('unsortable', '', '');
+ echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
+ foreach ($hooksPreRevPropChange as $hook) {
+ if (! empty($hook->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
+ echo '<tr style="display: none;" ><td>';
+ }
+ else {
+ echo '<tr><td>';
+ }
+ echo '<input type="checkbox" ';
+ echo 'name="'.$hook->getLabel().'_'.$hook->getClassname().'" ';
+ if (in_array($hook->getClassname(), $hooksEnabled))
+ echo ' checked="checked"';
+
+ if ($statusDeploy)
+ echo ' disabled="disabled"';
+
+ echo ' />';
+ echo '</td><td>';
+ echo $hook->getName();
+ echo '</td><td>';
+ echo $hook->getDescription();
+ echo '</td></tr>';
+ }
+ echo $HTML->listTableBottom();
+ }
+ if (count($hooksPostCommit)) {
+ echo '<h3>'._('post-commit Hooks').'</h3>';
+ $tabletop = array('', _('Hook Name'), _('Description'));
+ $classth = array('unsortable', '', '');
+ echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_postcommit', 'sortable', $classth);
+ foreach ($hooksPostCommit as $hookPostCommit) {
+ 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)
+ echo ' disabled="disabled"';
+
+ echo ' />';
+ echo '</td><td>';
+ echo $hookPostCommit->getName();
+ echo '</td><td>';
+ echo $hookPostCommit->getDescription();
+ echo '</td></tr>';
+ }
+ echo $HTML->listTableBottom();
+ }
+ }
+
+ function displayScmHgHook($hooksAvailable, $statusDeploy, $hooksEnabled) {
+ global $HTML;
+ $hooksServePushPullBundle = array();
+ foreach ($hooksAvailable as $hook) {
+ switch ($hook->getHookType()) {
+ case "serve-push-pull-bundle": {
+ $hooksServePushPullBundle[] = $hook;
+ break;
+ }
+ default: {
+ //byebye hook.... we do not know you...
+ break;
+ }
+ }
+ }
+ if (count($hooksServePushPullBundle)) {
+ echo '<h3>'._('serve-push-pull-bundle Hooks').'</h3>';
+ $tabletop = array('', _('Hook Name'), _('Description'));
+ $classth = array('unsortable', '', '');
+ echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_serve-push-pull-bundle', 'sortable', $classth);
+ foreach ($hooksServePushPullBundle as $hookServePushPullBundle) {
+ if (! empty($hookServePushPullBundle->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
+ echo '<tr style="display: none;" ><td>';
+ }
+ else {
+ echo '<tr><td>';
+ }
+ echo '<input type="checkbox" ';
+ echo 'name="'.$hookServePushPullBundle->getLabel().'_'.$hookServePushPullBundle->getClassname().'" ';
+ if (in_array($hookServePushPullBundle->getClassname(), $hooksEnabled))
+ echo ' checked="checked"';
+
+ if ($statusDeploy)
+ echo ' disabled="disabled"';
+
+ echo ' />';
+ echo '</td><td>';
+ echo $hookServePushPullBundle->getName();
+ echo '</td><td>';
+ echo $hookServePushPullBundle->getDescription();
+ echo '</td></tr>';
+ }
+ echo $HTML->listTableBottom();
+ }
+ }
}
// Local Variables:
<?php
/**
* Copyright 2011, Franck Villaume - Capgemini
+ * Copyright 2012, 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
}
break;
}
+ case 'scmhg': {
+ cron_debug("INFO start updating hooks for project ".$group->getUnixName());
+ include $gfplugins.'scmhook/library/'.$scmtype.'/cronjobs/updateScmRepo.php';
+ $params = array();
+ $params['group_id'] = $group_id;
+ $params['hooksString'] = $row['hooks'];
+ $params['scm_root'] = forge_get_config('repos_path', 'scmhg') . '/' . $group->getUnixName();
+ if (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;
--- /dev/null
+<?php
+/**
+ * scmhook commitEmail Plugin Class
+ * Copyright 2012, Denise Patzker <denise.patzker@tu-dresden.de>
+ * Copyright 2012, Franck Villaume - TrivialDev
+ *
+ * This class provides hook to activate/deactivate Mercurials e-mail
+ * notification per repository.
+ *
+ * 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 commitEmail extends scmhook {
+ function __construct() {
+ $this->name = "Commit Email";
+ $this->description = _('Every commit pushed sends a notification e-mail to the users of the commit-mailinglist.
+The hook is triggered after \'serve push pull bundle\' on the projects repository.');
+ $this->classname = "commitEmail";
+ $this->label = "scmhg";
+ $this->hooktype = "serve-push-pull-bundle";
+ $this->unixname = "commitemail";
+ $this->needcopy = 0;
+ $this->command = 'exit 0';
+ }
+
+ /**
+ * This function activates e-mail notification for pushed commits.
+ * This is done by adding the needed entries to the projects hgrc file.
+ */
+ function enable($project) {
+ if (!$project) {
+ return false;
+ }
+
+ $project_name = $project->getUnixName();
+ $root = forge_get_config('repos_path', 'scmhg') . '/' . $project_name;
+ $unix_group = forge_get_config('apache_group');
+ $unix_user = forge_get_config('apache_user');
+ $main_repo = $root . '/.hg';
+ if (is_dir("$main_repo")) {
+ $mail = $project_name.'-commits@'.forge_get_config('web_host');
+ $hgrc = "";
+
+ /*strip of repository path for subject line*/
+ $delim = "/";
+ $strip = count(explode($delim, $root))-1;
+
+ if (is_file($main_repo.'/hgrc')) {
+ /*set the needed entries within hgrc*/
+
+ $hgrc_val = parse_ini_file("$main_repo/hgrc", true);
+ if (!isset( $hgrc_val['extensions'])) {
+ /*makes notify extension usable*/
+ $hgrc_val['extensions']['hgext.notify'] = '';
+ }
+ if (!isset( $hgrc_val['hooks'])) {
+ /*activates the notify hook*/
+ $hgrc_val['hooks']['changegroup.notify'] = 'python:hgext.notify.hook';
+ }
+ if (!isset( $hgrc_val['email'])) {
+ /*set email parameter*/
+ $hgrc_val['email']['from'] = $mail;
+ $sendmail = forge_get_config('sendmail_path');
+ $hgrc_val['email']['method'] = $sendmail;
+ }
+ if (!isset( $hgrc_val['notify'])) {
+ /*define when notify does something*/
+ $hgrc_val['notify']['sources'] = 'serve push pull bundle';
+ /*test = true will not deliver the mail, instead you will get command line output*/
+ $hgrc_val['notify']['test'] = 'false';
+
+ /*configure subscribers*/
+ if (!isset( $hgrc_val['reposubs'])) {
+ $hgrc_val['reposubs']['**'] = $mail;
+ }
+ $hgrc_val['notify']['template'] = '"\ndetails: {webroot}/rev/{node|short}\nchangeset: {rev}:{node|short}\nuser: {author}\ndate:
+ {date|date}\ndescription:\n{desc}\n"' ;
+ $hgrc_val['notify']['maxdiff'] = '300';
+ $hgrc_val['notify']['strip'] = $strip;
+ } else {
+ /*parse_ini_file() has problems with boolean and special characters*/
+ $hgrc_val['notify']['test'] = 'false';
+ $hgrc_val['notify']['template'] = '"\ndetails: {webroot}/rev/{node|short}\nchangeset: {rev}:{node|short}\nuser: {author}\ndate:
+ {date|date}\ndescription:\n{desc}\n"';
+ }
+ /* write configuration back to file*/
+ foreach ($hgrc_val as $section => $sub) {
+ $hgrc .= '['.$section."]\n";
+ foreach ($sub as $prop => $value) {
+ $hgrc .= "$prop = $value\n";
+ if ($value == end($sub)) {
+ $hgrc .= "\n";
+ }
+ }
+ }
+ } else {
+ /*create new hgrc with default values*/
+ $hgrc .= "[web]\n";
+ $hgrc .= "baseurl = /hg";
+ $hgrc .= "\ndescription = ".$project_name;
+ $hgrc .= "\nstyle = paper";
+ $hgrc .= "\nallow_read = *";
+ $hgrc .= "\nallow_push = *\n\n";
+
+ $hgrc .= "[extensions]\n" ;
+ $hgrc .= "hgext.notify =\n\n";
+
+ $hgrc .= "[hooks]\n" ;
+ $hgrc .= "changegroup.notify = python:hgext.notify.hook\n\n";
+
+ $hgrc .= "[email]\n";
+ $hgrc .= "from = $mail\n";
+ $hgrc .= "method = $sendmail\n\n";
+
+ $hgrc .= "[notify]\n" ;
+ $hgrc .= "sources = serve push pull bundle\n";
+ $hgrc .= "test = false\n";
+ $hgrc .= 'template = "\ndetails: {webroot}/rev/{node|short}/\nchangeset: {rev}:{node|short}\nuser: {author}\ndate:
+ {date|date}\ndescription:\n{desc}\n"';
+ $hgrc .= "\nmaxdiff = 300\n";
+ $hgrc .= "strip = $strip\n\n";
+ $hgrc .= "[reposubs]\n";
+ $hgrc .= "** = $mail";
+ }
+ $f = fopen ("$main_repo/hgrc.new", 'w');
+ fwrite ($f, $hgrc);
+ fclose ($f);
+ rename ($main_repo.'/hgrc.new', $main_repo.'/hgrc');
+ system( "chown $unix_user:$unix_group $main_repo/hgrc" );
+ system( "chmod 660 $path/hgrc" );
+ }
+ return true;
+ }
+
+ /**
+ * This function deactivates e-mail notification.
+ * This is done by removing the needed entries from the projects hgrc file.
+ *
+ * @param $project object containing project data
+ */
+ function disable($project) {
+ if (!$project) {
+ return false;
+ }
+
+ $unix_group = forge_get_config('apache_group');
+ $unix_user = forge_get_config('apache_user');
+
+ $project_name = $project->getUnixName();
+ $root = forge_get_config('repos_path', 'scmhg') . '/' . $project_name;
+ $main_repo = $root . '/.hg';
+ if (is_file($main_repo.'/hgrc')) {
+ /*unset extension and hook to unable notification emails*/
+ $hgrc_val = parse_ini_file("$main_repo/hgrc", true);
+ if ( isset( $hgrc_val['extensions'] )) {
+ unset($hgrc_val['extensions']);
+ }
+ if ( isset( $hgrc_val['hooks'] )) {
+ unset($hgrc_val['hooks']);
+ }
+ if ( isset( $hgrc_val['notify']['test'] )) {
+ $hgrc_val['notify']['test'] = "false";
+ }
+ if ( isset( $hgrc_val['notify']['template'] )) {
+ $hgrc_val['notify']['template'] = '"\ndetails: {webroot}/rev/{node|short}\nchangeset: {rev}:{node|short}\nuser: {author}\ndate:
+ {date|date}\ndescription:\n{desc}\n"' ;
+ }
+
+ $hgrc = "" ;
+ foreach ($hgrc_val as $section => $sub) {
+ $hgrc .= '['.$section."]\n";
+ foreach ($sub as $prop => $value) {
+ $hgrc .= "$prop = $value\n";
+ if ($value == end($sub)) {
+ $hgrc .= "\n";
+ }
+ }
+ }
+
+ $f = fopen ("$main_repo/hgrc.new", 'w');
+ fwrite($f, $hgrc);
+ fclose($f);
+ rename($main_repo.'/hgrc.new', $main_repo.'/hgrc');
+ system( "chown $unix_user:$unix_group $main_repo/hgrc" );
+ system( "chmod 660 $main_repo/hgrc" );
+ }
+ return true;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2012, 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.
+ */
+
+/**
+ * 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
+ */
+
+/**
+ * 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'];
+ $scmdir_root = $params['scm_root'];
+ $group = group_get_object($group_id);
+ $scmhookPlugin = new scmhookPlugin;
+ $hooksAvailable = $scmhookPlugin->getAvailableHooks($group_id);
+ $unixname = $group->getUnixName();
+ if (is_dir($scmdir_root)) {
+ $hooksServePushPullBundle = array();
+ foreach ($hooksAvailable as $hook) {
+ switch ($hook->getHookType()) {
+ case "serve-push-pull-bundle": {
+ $hooksServePushPullBundle[] = $hook;
+ break;
+ }
+ default: {
+ //byebye hook.... we do not know you...
+ break;
+ }
+ }
+ }
+ //first we disable all hooks
+ foreach($hooksServePushPullBundle as $hookServePushPullBundle) {
+ $hookServePushPullBundle->disable($group);
+ }
+ //now we enable new available hooks
+ $newHooks = explode('|', $hooksString);
+ if (count($newHooks)) {
+ $hooksServePushPullBundle = array();
+ foreach($newHooks as $newHook) {
+ foreach($hooksServePushPullBundle as $hookServePushPullBundle) {
+ if ($hookServePushPullBundle->getClassname() == $newHook) {
+ $newHooksServePushPullBundle[] = $hookServePushPullBundle;
+ }
+ }
+ }
+ }
+ if (count($newHooksServePushPullBundle)) {
+ foreach($newHooksServePushPullBundle as $newHookServePushPullBundle) {
+ $newHookServePushPullBundle->enable($group);
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+?>
<?php
+/**
+ * scmhook allowRevPropChange Plugin Class
+ * Copyright 2011, Franck Villaume - Capgemini
+ * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, 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 allowRevPropChange extends scmhook {
- function allowRevPropChange() {
+ function __construct() {
$this->name = "Allow RevProp Changes";
$this->description = _('Allow SCM committers to change revision properties.');
$this->classname = "allowRevPropChange";
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class checkLog extends scmhook {
- function checkLog() {
+ function __construct() {
$this->name = "Check log";
$this->description = _('Commit message must not be empty.');
$this->classname = "checkLog";
* scmhook checkMimetype Plugin Class
* Copyright 2011, Franck Villaume - Capgemini
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * COpyright 2012, 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
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class checkMimetype extends scmhook {
- function checkMimetype() {
+ function __construct() {
$this->name = "Check Mimetype";
$this->description = _('Verify if commited files have svn:mimetype set up correctly.');
$this->classname = "checkMimetype";
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class commitEmail extends scmhook {
- function commitEmail() {
+ function __construct() {
$this->name = "Commit Email";
$this->description = _('Commit is pushed to commit mailing-list of the project');
$this->classname = "commitEmail";
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class commitTracker extends scmhook {
- function commitTracker() {
+ function __construct() {
$this->name = "Commit Tracker";
$this->description = _('Every commit is pushed into related tracker or task.');
$this->classname = "commitTracker";
*/
/**
- * scmsvn_updateScmRepo - update the scmrepo with the new hooks
+ * updateScmRepo - update the scmrepo with the new hooks
*
* @params Array the complete array description
* @return boolean success or not