Use JSON to obtain list of Gerrit repositories.
diff --git a/commits/repositories.php b/commits/repositories.php
index 32f7777..71c8fb9 100644
--- a/commits/repositories.php
+++ b/commits/repositories.php
@@ -124,12 +124,11 @@
$ssh = mysql_real_escape_string("ssh://userid@git.eclipse.org$repository");
$gerrit = mysql_real_escape_string(getGerritUrl($repository));
$http = mysql_real_escape_string(getHttpUrl($repository));
- $github = mysql_real_escape_string(getGitHubUrl($repository));
$google = mysql_real_escape_string(getGoogleSourceUrl($repository));
$description = mysql_real_escape_string(getDescription($repository));
dashboard_sql("insert ignore into repositories (name, path) values('$name', '$repository')");
- dashboard_sql("update repositories set name='$name', git='$git', ssh='$ssh', gerrit='$gerrit', google='$google', http='$http', github='$github', description='$description' where path='$repository'");
+ dashboard_sql("update repositories set name='$name', git='$git', ssh='$ssh', gerrit='$gerrit', google='$google', http='$http', description='$description' where path='$repository'");
}
function captureSvnRepository($path) {
@@ -170,14 +169,34 @@
$partial = $matches[1];
$gerrit = "https://git.eclipse.org/r/p/$partial";
- // Use the RESTful web service to determine if the repository is
- // available on Gerrit.
- $known = preg_split("/\n/", file_get_contents('https://git.eclipse.org/r/projects/'));
- if (in_array($partial, $known)) return $gerrit;
+ $known = getGerritRepositoryData();
+ if (isset($known[$partial])) return $gerrit;
return '';
}
+/**
+ * Pull in the list of known repositories from Gerrit.
+ *
+ * TODO This only works for eclipse.org
+ *
+ * @return mixed
+ */
+function getGerritRepositoryData() {
+ $file = fopen('https://git.eclipse.org/r/projects/', 'r');
+ fgets($file); // Skip the first line
+ $data = '';
+ while ($line = fgets($file)) $data .= $line;
+ fclose($file);
+
+ return json_decode($data, true);
+}
+
+/**
+ * @deprecated
+ * @param unknown $path
+ * @return string
+ */
function getGitHubUrl($path) {
$url = "https://github.com/eclipse/" . getName($path);
return isValidUrl($url) ? $url : '';