* $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;
+
+class ScmHgUpdateScmRepo {
+ function __construct() {
+ return true;
+ }
+
+ /**
+ * 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;
+ //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);
+ if (count($newHooksServePushPullBundle)) {
+ foreach($newHooksServePushPullBundle as $newHookServePushPullBundle) {
+ $newHookServePushPullBundle->enable($group);
+ }
}
+ return true;
}
- return true;
+ return false;
}
- return false;
}
?>
* $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'];
- $svndir_root = $params['scm_root'];
- $group = group_get_object($group_id);
- $scmhookPlugin = new scmhookPlugin;
- $hooksAvailable = $scmhookPlugin->getAvailableHooks($group_id);
- $unixname = $group->getUnixName();
+class ScmSvnUpdateScmRepo {
+ function __construct() {
+ return true;
+ }
- if (is_dir($svndir_root)) {
- @unlink($svndir_root.'/hooks/pre-commit');
- @unlink($svndir_root.'/hooks/post-commit');
- $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 validate you...
- break;
+ /**
+ * 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'];
+ $svndir_root = $params['scm_root'];
+ $group = group_get_object($group_id);
+ $scmhookPlugin = new scmhookPlugin;
+ $hooksAvailable = $scmhookPlugin->getAvailableHooks($group_id);
+ $unixname = $group->getUnixName();
+
+ if (is_dir($svndir_root)) {
+ @unlink($svndir_root.'/hooks/pre-commit');
+ @unlink($svndir_root.'/hooks/post-commit');
+ $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 validate you...
+ break;
+ }
}
}
- }
- foreach($hooksPreCommit as $hookPreCommit) {
- if ($hookPreCommit->needCopy()) {
- foreach($hookPreCommit->getFiles() as $hookPreCommitFile) {
- @unlink($svndir_root.'/hooks/'.basename($hookPreCommitFile));
+ foreach($hooksPreCommit as $hookPreCommit) {
+ if ($hookPreCommit->needCopy()) {
+ foreach($hookPreCommit->getFiles() as $hookPreCommitFile) {
+ @unlink($svndir_root.'/hooks/'.basename($hookPreCommitFile));
+ }
}
}
- }
- foreach($hooksPreRevPropChange as $hook) {
- if ($hook->needCopy()) {
- foreach($hook->getFiles() as $file) {
- @unlink($svndir_root.'/hooks/'.basename($file));
+ foreach($hooksPreRevPropChange as $hook) {
+ if ($hook->needCopy()) {
+ foreach($hook->getFiles() as $file) {
+ @unlink($svndir_root.'/hooks/'.basename($file));
+ }
}
}
- }
- foreach($hooksPostCommit as $hookPostCommit) {
- if ($hookPostCommit->needCopy()) {
- foreach($hookPostCommit->getFiles() as $hookPostCommitFile) {
- @unlink($svndir_root.'/hooks/'.basename($hookPostCommitFile));
+ foreach($hooksPostCommit as $hookPostCommit) {
+ if ($hookPostCommit->needCopy()) {
+ foreach($hookPostCommit->getFiles() as $hookPostCommitFile) {
+ @unlink($svndir_root.'/hooks/'.basename($hookPostCommitFile));
+ }
}
}
- }
- $newHooks = explode('|', $hooksString);
- if (count($newHooks)) {
- $newHooksPreCommit = array();
- $newHooksPreRevPropChange = array();
- $newHooksPostCommit = array();
- foreach($newHooks as $newHook) {
- foreach($hooksPreCommit as $hookPreCommit) {
- if ($hookPreCommit->getClassname() == $newHook) {
- $newHooksPreCommit[] = $hookPreCommit;
+ $newHooks = explode('|', $hooksString);
+ if (count($newHooks)) {
+ $newHooksPreCommit = array();
+ $newHooksPreRevPropChange = array();
+ $newHooksPostCommit = array();
+ foreach($newHooks as $newHook) {
+ foreach($hooksPreCommit as $hookPreCommit) {
+ if ($hookPreCommit->getClassname() == $newHook) {
+ $newHooksPreCommit[] = $hookPreCommit;
+ }
}
- }
- foreach($hooksPreRevPropChange as $hook) {
- if ($hook->getClassname() == $newHook) {
- $newHooksPreRevPropChange[] = $hook;
+ foreach($hooksPreRevPropChange as $hook) {
+ if ($hook->getClassname() == $newHook) {
+ $newHooksPreRevPropChange[] = $hook;
+ }
}
- }
- foreach($hooksPostCommit as $hookPostCommit) {
- if ($hookPostCommit->getClassname() == $newHook) {
- $newHooksPostCommit[] = $hookPostCommit;
+ foreach($hooksPostCommit as $hookPostCommit) {
+ if ($hookPostCommit->getClassname() == $newHook) {
+ $newHooksPostCommit[] = $hookPostCommit;
+ }
}
}
}
- }
- foreach($newHooksPreCommit as $newHookPreCommit) {
- if ($newHookPreCommit->needCopy()) {
- foreach ($newHookPreCommit->getFiles() as $file) {
- copy($file, $svndir_root.'/hooks/'.basename($file));
- chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ foreach($newHooksPreCommit as $newHookPreCommit) {
+ if ($newHookPreCommit->needCopy()) {
+ foreach ($newHookPreCommit->getFiles() as $file) {
+ copy($file, $svndir_root.'/hooks/'.basename($file));
+ chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ }
}
}
- }
- foreach($hooksPreRevPropChange as $newHook) {
- if ($newHook->needCopy()) {
- foreach ($newHook->getFiles() as $file) {
- copy($file, $svndir_root.'/hooks/'.basename($file));
- chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ foreach($hooksPreRevPropChange as $newHook) {
+ if ($newHook->needCopy()) {
+ foreach ($newHook->getFiles() as $file) {
+ copy($file, $svndir_root.'/hooks/'.basename($file));
+ chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ }
}
}
- }
- foreach($newHooksPostCommit as $newHookPostCommit) {
- if ($newHookPostCommit->needCopy()) {
- foreach ($newHookPostCommit->getFiles() as $file) {
- copy($file, $svndir_root.'/hooks/'.basename($file));
- chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ foreach($newHooksPostCommit as $newHookPostCommit) {
+ if ($newHookPostCommit->needCopy()) {
+ foreach ($newHookPostCommit->getFiles() as $file) {
+ copy($file, $svndir_root.'/hooks/'.basename($file));
+ chmod($svndir_root.'/hooks/'.basename($file), 0755);
+ }
}
}
- }
- if (count($newHooksPreCommit)) {
- // prepare the pre-commit
- $file = fopen("/tmp/pre-commit-$unixname.tmp", "w");
- fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/pre-commit/head'));
- $string = '';
- foreach($newHooksPreCommit as $newHookPreCommit) {
- $string .= $newHookPreCommit->getHookCmd()."\n";
+ if (count($newHooksPreCommit)) {
+ // prepare the pre-commit
+ $file = fopen("/tmp/pre-commit-$unixname.tmp", "w");
+ fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/pre-commit/head'));
+ $string = '';
+ foreach($newHooksPreCommit as $newHookPreCommit) {
+ $string .= $newHookPreCommit->getHookCmd()."\n";
+ }
+ $string .= "\n";
+ fwrite($file, $string);
+ fclose($file);
+ copy('/tmp/pre-commit-'.$unixname.'.tmp', $svndir_root.'/hooks/pre-commit');
+ chmod($svndir_root.'/hooks/pre-commit', 0755);
+ unlink('/tmp/pre-commit-'.$unixname.'.tmp');
+ } else {
+ @unlink($svndir_root.'/hooks/pre-commit');
}
- $string .= "\n";
- fwrite($file, $string);
- fclose($file);
- copy('/tmp/pre-commit-'.$unixname.'.tmp', $svndir_root.'/hooks/pre-commit');
- chmod($svndir_root.'/hooks/pre-commit', 0755);
- unlink('/tmp/pre-commit-'.$unixname.'.tmp');
- } else {
- @unlink($svndir_root.'/hooks/pre-commit');
- }
- if (count($newHooksPreRevPropChange)) {
- // prepare the pre-revprop-change
- $file = fopen("/tmp/pre-revprop-change-$unixname.tmp", "w");
- fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/pre-revprop-change/head'));
- $string = '';
- foreach($newHooksPreRevPropChange as $hook) {
- $string .= $hook->getHookCmd()."\n";
+ if (count($newHooksPreRevPropChange)) {
+ // prepare the pre-revprop-change
+ $file = fopen("/tmp/pre-revprop-change-$unixname.tmp", "w");
+ fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/pre-revprop-change/head'));
+ $string = '';
+ foreach($newHooksPreRevPropChange as $hook) {
+ $string .= $hook->getHookCmd()."\n";
+ }
+ $string .= "\n";
+ fwrite($file, $string);
+ fclose($file);
+ copy('/tmp/pre-revprop-change-'.$unixname.'.tmp', $svndir_root.'/hooks/pre-revprop-change');
+ chmod($svndir_root.'/hooks/pre-revprop-change', 0755);
+ unlink('/tmp/pre-revprop-change-'.$unixname.'.tmp');
+ } else {
+ @unlink($svndir_root.'/hooks/pre-revprop-change');
}
- $string .= "\n";
- fwrite($file, $string);
- fclose($file);
- copy('/tmp/pre-revprop-change-'.$unixname.'.tmp', $svndir_root.'/hooks/pre-revprop-change');
- chmod($svndir_root.'/hooks/pre-revprop-change', 0755);
- unlink('/tmp/pre-revprop-change-'.$unixname.'.tmp');
- } else {
- @unlink($svndir_root.'/hooks/pre-revprop-change');
- }
- if (count($newHooksPostCommit)) {
- // prepare the post-commit
- $file = fopen("/tmp/post-commit-$unixname.tmp", "w");
- fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/post-commit/head'));
- $string = '';
- foreach($newHooksPostCommit as $newHookPostCommit) {
- $string .= $newHookPostCommit->getHookCmd()."\n";
+ if (count($newHooksPostCommit)) {
+ // prepare the post-commit
+ $file = fopen("/tmp/post-commit-$unixname.tmp", "w");
+ fwrite($file, file_get_contents(dirname(__FILE__).'/../skel/post-commit/head'));
+ $string = '';
+ foreach($newHooksPostCommit as $newHookPostCommit) {
+ $string .= $newHookPostCommit->getHookCmd()."\n";
+ }
+ $string .= "\n";
+ fwrite($file, $string);
+ fclose($file);
+ copy('/tmp/post-commit-'.$unixname.'.tmp', $svndir_root.'/hooks/post-commit');
+ chmod($svndir_root.'/hooks/post-commit', 0755);
+ unlink('/tmp/post-commit-'.$unixname.'.tmp');
}
- $string .= "\n";
- fwrite($file, $string);
- fclose($file);
- copy('/tmp/post-commit-'.$unixname.'.tmp', $svndir_root.'/hooks/post-commit');
- chmod($svndir_root.'/hooks/post-commit', 0755);
- unlink('/tmp/post-commit-'.$unixname.'.tmp');
+ return true;
}
- return true;
+ return false;
}
- return false;
}
?>