[Fusionforge-commits] r16119 - in trunk/src/plugins/scmhook: common library/scmhg library/scmhg/cronjobs library/scmsvn
Franck VILLAUME
nerville at fusionforge.org
Sun Aug 19 19:33:48 CEST 2012
Author: nerville
Date: 2012-08-19 19:33:47 +0200 (Sun, 19 Aug 2012)
New Revision: 16119
Modified:
trunk/src/plugins/scmhook/common/scmhook.class.php
trunk/src/plugins/scmhook/common/scmhookPlugin.class.php
trunk/src/plugins/scmhook/library/scmhg/commitEmail.class.php
trunk/src/plugins/scmhook/library/scmhg/cronjobs/updateScmRepo.php
trunk/src/plugins/scmhook/library/scmsvn/commitEmail.class.php
trunk/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
Log:
add dependency tracking for hook availability : commitemail needs mailing-list ...
Modified: trunk/src/plugins/scmhook/common/scmhook.class.php
===================================================================
--- trunk/src/plugins/scmhook/common/scmhook.class.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/common/scmhook.class.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -2,6 +2,7 @@
/**
* scmhook Class
* 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
@@ -65,5 +66,13 @@
function getFiles() {
return $this->files;
}
+
+ function isAvailable() {
+ return true;
+ }
+
+ function getDisabledMessage() {
+ return _('Feature not implemented.');
+ }
}
?>
Modified: trunk/src/plugins/scmhook/common/scmhookPlugin.class.php
===================================================================
--- trunk/src/plugins/scmhook/common/scmhookPlugin.class.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/common/scmhookPlugin.class.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -284,6 +284,7 @@
$classth = array('unsortable', '', '');
echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
foreach ($hooksPreCommit as $hookPreCommit) {
+ $isdisabled = 0;
if (! empty($hookPreCommit->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
echo '<tr style="display: none;" ><td>';
}
@@ -295,11 +296,19 @@
if (in_array($hookPreCommit->getClassname(), $hooksEnabled))
echo ' checked="checked"';
- if ($statusDeploy)
+ if ($statusDeploy) {
+ $isdisabled = 1;
echo ' disabled="disabled"';
+ }
+ if (!$isdisabled && !$hookPreCommit->isAvailable())
+ echo ' disabled="disabled"';
echo ' />';
- echo '</td><td>';
+ echo '</td><td';
+ if (!$hookPreCommit->isAvailable())
+ echo ' class="tabtitle-w" title="'.$hookPreCommit->getDisabledMessage().'"';
+
+ echo ' >';
echo $hookPreCommit->getName();
echo '</td><td>';
echo $hookPreCommit->getDescription();
@@ -313,6 +322,7 @@
$classth = array('unsortable', '', '');
echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_precommit', 'sortable', $classth);
foreach ($hooksPreRevPropChange as $hook) {
+ $isdisabled = 0;
if (! empty($hook->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
echo '<tr style="display: none;" ><td>';
}
@@ -324,11 +334,19 @@
if (in_array($hook->getClassname(), $hooksEnabled))
echo ' checked="checked"';
- if ($statusDeploy)
+ if ($statusDeploy) {
+ $isdisabled = 1;
echo ' disabled="disabled"';
+ }
+ if (!$isdisabled && !$hook->isAvailable())
+ echo ' disabled="disabled"';
echo ' />';
- echo '</td><td>';
+ echo '</td><td';
+ if (!$hook->isAvailable())
+ echo ' class="tabtitle-w" title="'.$hook->getDisabledMessage().'"';
+
+ echo ' >';
echo $hook->getName();
echo '</td><td>';
echo $hook->getDescription();
@@ -342,6 +360,7 @@
$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>';
}
@@ -353,11 +372,20 @@
if (in_array($hookPostCommit->getClassname(), $hooksEnabled))
echo ' checked="checked"';
- if ($statusDeploy)
+ if ($statusDeploy) {
+ $isdisabled = 1;
echo ' disabled="disabled"';
+ }
+ if (!$isdisabled && !$hookPostCommit->isAvailable())
+ echo ' disabled="disabled"';
+
echo ' />';
- echo '</td><td>';
+ echo '</td><td';
+ if (!$hookPostCommit->isAvailable())
+ echo ' class="tabtitle-w" title="'.$hookPostCommit->getDisabledMessage().'"';
+
+ echo ' >';
echo $hookPostCommit->getName();
echo '</td><td>';
echo $hookPostCommit->getDescription();
@@ -388,6 +416,7 @@
$classth = array('unsortable', '', '');
echo $HTML->listTableTop($tabletop, false, 'sortable_scmhook_serve-push-pull-bundle', 'sortable', $classth);
foreach ($hooksServePushPullBundle as $hookServePushPullBundle) {
+ $isdisabled = 0;
if (! empty($hookServePushPullBundle->onlyGlobalAdmin) && ! Permission::isGlobalAdmin()) {
echo '<tr style="display: none;" ><td>';
}
@@ -399,11 +428,20 @@
if (in_array($hookServePushPullBundle->getClassname(), $hooksEnabled))
echo ' checked="checked"';
- if ($statusDeploy)
+ if ($statusDeploy) {
+ $isdisabled = 1;
echo ' disabled="disabled"';
+ }
+ if (!$isdisabled && !$hookServePushPullBundle->isAvailable())
+ echo ' disabled="disabled"';
+
echo ' />';
- echo '</td><td>';
+ echo '</td><td';
+ if (!$hookServePushPullBundle->isAvailable())
+ echo ' class="tabtitle-w" title="'.$hookServePushPullBundle->getDisabledMessage().'"';
+
+ echo ' >';
echo $hookServePushPullBundle->getName();
echo '</td><td>';
echo $hookServePushPullBundle->getDescription();
Modified: trunk/src/plugins/scmhook/library/scmhg/commitEmail.class.php
===================================================================
--- trunk/src/plugins/scmhook/library/scmhg/commitEmail.class.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/library/scmhg/commitEmail.class.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -27,7 +27,11 @@
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class commitEmail extends scmhook {
+ var $group;
+ var $disabledMessage;
+
function __construct() {
+ $this->group = $GLOBALS['group'];
$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.');
@@ -39,6 +43,29 @@
$this->command = 'exit 0';
}
+ function isAvailable() {
+ global $gfcommon;
+ require_once $gfcommon.'mail/MailingList.class.php';
+ require_once $gfcommon.'mail/MailingListFactory.class.php';
+ if ($this->group->usesMail()) {
+ $mlFactory = new MailingListFactory($group);
+ $mlArray = $mlFactory->getMailingLists();
+ for ($j = 0; $j < $mlCount; $j++) {
+ $currentList =& $mlArray[$j];
+ if ($currentList->getListEmail() == $this->group->getUnixName().'-commits@'.forge_get_config('lists_host'))
+ return true;
+ }
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
+ } else {
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project not using mailing-list.');
+ }
+ return false;
+ }
+
+ function getDisabledMessage() {
+ return $this->disabledMessage;
+ }
+
/**
* This function activates e-mail notification for pushed commits.
* This is done by adding the needed entries to the projects hgrc file.
Modified: trunk/src/plugins/scmhook/library/scmhg/cronjobs/updateScmRepo.php
===================================================================
--- trunk/src/plugins/scmhook/library/scmhg/cronjobs/updateScmRepo.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/library/scmhg/cronjobs/updateScmRepo.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -76,7 +76,7 @@
}
}
}
- if (count($newHooksServePushPullBundle)) {
+ if (isset($newHooksServePushPullBundle) && count($newHooksServePushPullBundle)) {
foreach($newHooksServePushPullBundle as $newHookServePushPullBundle) {
$newHookServePushPullBundle->enable($group);
}
Modified: trunk/src/plugins/scmhook/library/scmsvn/commitEmail.class.php
===================================================================
--- trunk/src/plugins/scmhook/library/scmsvn/commitEmail.class.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/library/scmsvn/commitEmail.class.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -2,6 +2,7 @@
/**
* scmhook commitEmail Plugin Class
* 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
@@ -23,16 +24,43 @@
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class commitEmail extends scmhook {
+ var $group;
+ var $disabledMessage;
+
function __construct() {
+ $this->group = $GLOBALS['group'];
$this->name = "Commit Email";
- $this->description = _('Commit is pushed to commit mailing-list of the project');
+ $this->description = _('Commit message log is pushed to commit mailing-list of the project');
$this->classname = "commitEmail";
$this->hooktype = "post-commit";
$this->label = "scmsvn";
$this->unixname = "commitemail";
$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.'/commit-email.php "$1" "$2" '.$GLOBALS['group']->getUnixName().'-commits@'.forge_get_config('lists_host');
+ $this->label.'/hooks/'.$this->unixname.'/commit-email.php "$1" "$2" '.$this->group->getUnixName().'-commits@'.forge_get_config('lists_host');
}
+
+ function isAvailable() {
+ global $gfcommon;
+ require_once $gfcommon.'mail/MailingList.class.php';
+ require_once $gfcommon.'mail/MailingListFactory.class.php';
+ if ($this->group->usesMail()) {
+ $mlFactory = new MailingListFactory($group);
+ $mlArray = $mlFactory->getMailingLists();
+ for ($j = 0; $j < $mlCount; $j++) {
+ $currentList =& $mlArray[$j];
+ if ($currentList->getListEmail() == $this->group->getUnixName().'-commits@'.forge_get_config('lists_host'))
+ return true;
+ }
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
+ } else {
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project not using mailing-list.');
+ }
+ return false;
+ }
+
+ function getDisabledMessage() {
+ return $this->disabledMessage;
+ }
}
?>
Modified: trunk/src/plugins/scmhook/library/scmsvn/commitTracker.class.php
===================================================================
--- trunk/src/plugins/scmhook/library/scmsvn/commitTracker.class.php 2012-08-19 15:40:01 UTC (rev 16118)
+++ trunk/src/plugins/scmhook/library/scmsvn/commitTracker.class.php 2012-08-19 17:33:47 UTC (rev 16119)
@@ -26,7 +26,11 @@
require_once $gfplugins.'scmhook/common/scmhook.class.php';
class commitTracker extends scmhook {
+ var $group;
+ var $disabledMessage;
+
function __construct() {
+ $this->group = $GLOBALS['group'];
$this->name = "Commit Tracker";
$this->description = _('Every commit is pushed into related tracker or task.');
$this->classname = "commitTracker";
@@ -38,6 +42,18 @@
$this->label.'/hooks/'.$this->unixname.'/post.php "$1" "$2"';
}
+ function isAvailable() {
+ if ($this->group->usesTracker()) {
+ return true;
+ }
+ $this->disabledMessage = _('Hook not available due to missing dependency : Project not using tracker.');
+ return false;
+ }
+
+ function getDisabledMessage() {
+ return $this->disabledMessage;
+ }
+
function artifact_extra_detail($params) {
$DBResult = db_query_params('SELECT * FROM plugin_scmhook_scmsvn_committracker_data_master, plugin_scmhook_scmsvn_committracker_data_artifact
WHERE plugin_scmhook_scmsvn_committracker_data_artifact.group_artifact_id = $1
More information about the Fusionforge-commits
mailing list