summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-11-22 14:13:03 +0100
committerErich Eckner <git@eckner.net>2019-11-22 14:13:03 +0100
commitbf9d8b1e6cadf95b7c3ebc45767a55e6c197914f (patch)
tree0a6da82a9bbcb59f0c639c47777831a221a83fa8 /lib
parentd7a134060e2bab184ae0346ee65cd84f3981ab70 (diff)
downloadarchweb32-bf9d8b1e6cadf95b7c3ebc45767a55e6c197914f.tar.xz
lib/helper.php: $git_available should only change the host part of the url
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php91
1 files changed, 34 insertions, 57 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 043fab9..debfb06 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -99,64 +99,41 @@ function git_url($repository,$type,$commit,$path,$line = null,$commit_is_hash =
}
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/" .
- $repository .
- "/src/" .
- $commit .
- "/" .
- $path .
- $line;
- case "log":
- return
- "https://git.archlinux32.org/" .
- $repository .
- "/commits/" .
- $commit .
- "/" .
- $path .
- $line;
- }
+ if ($git_available)
+ $host = "git.archlinux32.org";
+ else
+ $host = "git2.archlinux32.org";
- } 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/" .
- $repository .
- "/tree/" .
- $path .
- $commit .
- $line;
- case "log":
- return
- "https://git2.archlinux32.org/" .
- $repository .
- "/log/" .
- $path .
- $commit .
- $line;
- }
- };
+ 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://" .
+ $host .
+ "/" .
+ $repository .
+ "/tree/" .
+ $path .
+ $commit .
+ $line;
+ case "log":
+ return
+ "https://" .
+ $host .
+ "/" .
+ $repository .
+ "/log/" .
+ $path .
+ $commit .
+ $line;
+ }
};
function if_unset($array, $index, $default) {