blob: 6ac301c85b1ac8079a8ed44b2c176107d42085c9 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2010, 2012 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
*******************************************************************************/
$path = '/gitroot/';
//$path = '/home/wayne/git/';
$find="find $path -type d -name *.git | xargs -I '{}' git --git-dir={} rev-parse --git-dir 2> /dev/null";
$handle = popen($find, 'r');
while ($repository = fgets($handle)) {
captureRepository(trim($repository));
}
pclose($handle);
function captureRepository($repository) {
$name = getName($repository);
$git = "git://git.eclipse.org$repository";
$gerrit = getGerritLink($repository);
$http = getHttpLink($repository);
$github = "https://github.com/eclipse/$name";
echo "update repositories set name='$name' git='$git' gerrit='$gerrit' http='$http' github='$github' where repo='$git');\n";
}
function getName($path) {
if (preg_match('/org\.eclipse\.(.*)\.git$/', $path, $matches)) {
return $matches[1];
} else if (preg_match('/org\.eclipse\.(.*)$/', $path, $matches)) {
return $matches[1];
} else if (preg_match('/([^\/]*)\.git$/', $path, $matches)) {
return $matches[1];
} else if (preg_match('/([^\/]*)$/', $path, $matches)) {
return $matches[1];
} else {
return $this->path;
}
}
function getHttpLink($path) {
preg_match('/\/gitroot\/(.+)/', $path, $matches);
$partial = $matches[1];
return "http://git.eclipse.org/c/$partial";
}
function getGerritLink($path) {
preg_match('/\/gitroot\/(.+)/', $path, $matches);
$partial = $matches[1];
$gerrit = "https://git.eclipse.org/r/p/$partial";
return $gerrit;
}
// Pull in a list of repostories
// For each...
// Grab the description file, remember the contents.
// Build the probable Gerrit URL, test. If not 404, remember.
// Build the probable GitHub URL, test. If not 404, remember.
?>