Skip to content

Instantly share code, notes, and snippets.

@sudhanshuraheja
Created May 5, 2010 11:07
Show Gist options
  • Save sudhanshuraheja/390643 to your computer and use it in GitHub Desktop.
Save sudhanshuraheja/390643 to your computer and use it in GitHub Desktop.
<?php
$hooks_dir = '/svn/hooks/';
$repos_dir = '/svn/svn.localhost/';
$repo_hook_dir = $repos_dir . '__REPO__/hooks/';
if($hooks = opendir($hooks_dir)) {
while(($hook = readdir($hooks)) !== false) {
$unwanted = array('.', '..');
if(!in_array($hook, $unwanted)) {
if($repos = opendir($repos_dir)) {
while(($repo = readdir($repos)) !== false) {
if(!in_array($repo, $unwanted) && is_dir(repoPath($repo))) {
if(!copy($hooks_dir . $hook, repoPath($repo) . $hook)) {
echo "Could not copy " . $hooks_dir . $hook . " to " . repoPath($repo) . "\n";
}
if(!chmod(repoPath($repo) . $hook, 0755)) {
echo "Could not chmod " . repoPath($repo) . $repo . "\n";
}
}
}
closedir($hooks);
}
}
}
closedir($hooks);
}
function repoPath($repo) {
global $repo_hook_dir;
return str_replace('__REPO__', $repo, $repo_hook_dir);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment