summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildmaster/build-list.php16
-rw-r--r--buildmaster/todos.php6
-rw-r--r--lib/helper.php74
-rw-r--r--packages/pkginfo.php13
4 files changed, 92 insertions, 17 deletions
diff --git a/buildmaster/build-list.php b/buildmaster/build-list.php
index 1b4466f..2ff9b92 100644
--- a/buildmaster/build-list.php
+++ b/buildmaster/build-list.php
@@ -1,6 +1,7 @@
<?php
require_once "../init.php";
+require_once BASE . "/lib/helper.php";
require_once BASE . "/lib/mysql.php";
require_once BASE . "/lib/style.php";
@@ -82,13 +83,14 @@ $columns = array(
"mysql_query" =>
"IF(`ba_q`.`uses_modification`," .
"CONCAT(" .
- "\"<a href=\\\"https://git.archlinux32.org/archlinux32/packages/src/commit/\"," .
- "`ba_q`.`mod_git_revision`," .
- "\"/\"," .
- "`ba_q`.`package_repository`," .
- "\"/\"," .
- "`ba_q`.`pkgbase`," .
- "\"\\\">\"," .
+ "\"<a href=\\\"" .
+ git_url(
+ "packages",
+ "tree",
+ "\",`ba_q`.`mod_git_revision`,\"",
+ "\",`ba_q`.`package_repository`,\"/\",`ba_q`.`pkgbase`,\""
+ ) .
+ "\\\">\"," .
"`ba_q`.`mod_git_revision`," .
"\"</a>\"" .
")," .
diff --git a/buildmaster/todos.php b/buildmaster/todos.php
index e3d7319..bf77f08 100644
--- a/buildmaster/todos.php
+++ b/buildmaster/todos.php
@@ -1,5 +1,7 @@
<?php
require_once "../init.php";
+
+include BASE . "/lib/helper.php";
include BASE . "/lib/mysql.php";
$result = mysql_run_query(
@@ -76,7 +78,9 @@ if (isset($_GET["graph"])) {
while ($row = $result->fetch_assoc()) {
print "<a href=\"#TODO" . $row["id"] . "\" name=\"TODO" . $row["id"] ."\">TODO #" . $row["id"] . "</a>";
print " - ";
- print "<a href=\"https://git.archlinux32.org/archlinux32/builder/src/branch/master/" . $row["file"] . "#L" . $row["line"] . "\">" . $row["file"] . "(line " . $row["line"] . ")</a>";
+ print "<a href=\"";
+ print git_url("builder","tree","master",$row["file"],$row["line"]);
+ print "\">" . $row["file"] . "(line " . $row["line"] . ")</a>";
print ":<br>\n";
print str_replace("\\n","<br>\n",$row["description"]);
print "<br>\n";
diff --git a/lib/helper.php b/lib/helper.php
index 41951c7..732b52a 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -83,4 +83,76 @@ function format_time_duration($val) {
$result
);
return $result;
-}
+};
+
+function git_url($repository,$type,$commit,$path,$line = null,$commit_is_hash = null) {
+ global $git_available;
+ # TODO: we might want to cache this value (with memcached ?)
+ if (!isset($git_available)) {
+ $git_available =
+ preg_match(
+ "/ 200 OK$/",
+ get_headers("https://git.archlinux32.org/archlinux32/packagess")[0]
+ ) == 1;
+ }
+ if (!isset($commit_is_hash))
+ $commit_is_hash = preg_match("/^[0-9a-f]{40}$/",$commit)==1;
+ if ($git_available) {
+ if (isset($line))
+ $line = "#L" . $line;
+ else
+ $line = "";
+ if ($commit_is_hash)
+ $commit = "commit/" . $commit;
+ else
+ $commit = "branch/" . $commit;
+ switch ($type) {
+ case "tree":
+ return
+ "https://git.archlinux32.org/archlinux32/" .
+ $repository .
+ "/src/" .
+ $commit .
+ "/" .
+ $path .
+ $line;
+ case "log":
+ return
+ "https://git.archlinux32.org/archlinux32/" .
+ $repository .
+ "/commits/" .
+ $commit .
+ "/" .
+ $path .
+ $line;
+ }
+
+ } else {
+ if (isset($line))
+ $line = "#n" . $line;
+ else
+ $line = "";
+ if ($commit_is_hash)
+ $commit = "?id=" . $commit;
+ else
+ $commit = "?h=" . $commit;
+ switch ($type) {
+ case "tree":
+ return
+ "https://git2.archlinux32.org/Archlinux32/" .
+ $repository .
+ "/tree/" .
+ $path .
+ $commit .
+ $line;
+ case "log":
+ return
+ "https://git2.archlinux32.org/Archlinux32/" .
+ $repository .
+ "/log/" .
+ $path .
+ $commit .
+ $line;
+ }
+ };
+};
diff --git a/packages/pkginfo.php b/packages/pkginfo.php
index b910266..3fa1e77 100644
--- a/packages/pkginfo.php
+++ b/packages/pkginfo.php
@@ -1,6 +1,7 @@
<?php
require_once "../init.php";
+require_once BASE . "/lib/helper.php";
require_once BASE . "/lib/mysql.php";
require_once BASE . "/lib/style.php";
@@ -283,17 +284,13 @@ require_once BASE . "/lib/style.php";
}
if ($content["uses_modification"]) {
print " <li>\n";
- print " <a href=\"https://git.archlinux32.org/archlinux32/packages/src/branch/master/";
- print $content["stable_repo"];
- print "/";
- print $content["pkgbase"];
+ print " <a href=\"";
+ print git_url("packages","tree","master",$content["stable_repo"]."/".$content["pkgbase"]);
print "\" title=\"View archlinux32's source files for ";
print $content["pkgname"];
print "\">Archlinux32's Source Files</a> /\n";
- print " <a href=\"https://git.archlinux32.org/archlinux32/packages/commits/branch/master/";
- print $content["stable_repo"];
- print "/";
- print $content["pkgbase"];
+ print " <a href=\"";
+ print git_url("packages","log","master",$content["stable_repo"]."/".$content["pkgbase"]);
print "\" title=\"View upstream's changes for ";
print $content["pkgname"];
print "\">Archlinux32's Changes</a>\n";