diff --git a/app/Utils/RepositoryUtils.php b/app/Utils/RepositoryUtils.php index f22a290e01..a7a8c37a28 100644 --- a/app/Utils/RepositoryUtils.php +++ b/app/Utils/RepositoryUtils.php @@ -357,23 +357,6 @@ public static function get_gitweb2_diff_url($projecturl, $directory, $file, $rev return make_cdash_url($diff_url); } - /** Return the Gitorious/GitHub diff URL */ - public static function get_gitoriousish_diff_url($projecturl, $directory, $file, $revision, $blobs, $branch = 'master') - { - if ($revision != '') { - $diff_url = $projecturl . '/commit/' . $revision; - } elseif ($file != '') { - $diff_url = $projecturl . '/' . $blobs . '/' . $branch . '/'; - if ($directory != '') { - $diff_url .= $directory . '/'; - } - $diff_url .= $file; - } else { - return ''; - } - return make_cdash_url($diff_url); - } - /** Return the Stash diff URL */ public static function get_stash_diff_url($projecturl, $directory, $file, $revision) { @@ -388,8 +371,18 @@ public static function get_stash_diff_url($projecturl, $directory, $file, $revis /** Return the Gitorious diff URL */ public static function get_gitorious_diff_url($projecturl, $directory, $file, $revision) { - // Gitorious uses 'blobs' or 'trees' (plural) - return self::get_gitoriousish_diff_url($projecturl, $directory, $file, $revision, 'blobs'); + if ($revision !== '') { + $diff_url = $projecturl . '/commit/' . $revision; + } elseif ($file !== '') { + $diff_url = $projecturl . '/blobs/master/'; + if ($directory !== '') { + $diff_url .= $directory . '/'; + } + $diff_url .= $file; + } else { + return ''; + } + return make_cdash_url($diff_url); } /** Return the source directory for a source file */ @@ -449,8 +442,20 @@ public static function get_github_diff_url($projecturl, $directory, $file, $revi /** Return the GitLab diff URL */ public static function get_gitlab_diff_url($projecturl, $directory, $file, $revision) { - // GitLab uses 'blob' or 'tree' (singular, no s) - return self::get_gitoriousish_diff_url($projecturl, $directory, $file, $revision, 'blob'); + // Since GitLab supports arbitrarily nested groups, there is a `/-/` + // component to start per-project resources. + if ($revision !== '') { + $diff_url = $projecturl . '/-/commit/' . $revision; + } elseif ($file !== '') { + $diff_url = $projecturl . '/-/blob/master/'; + if ($directory !== '') { + $diff_url .= $directory . '/'; + } + $diff_url .= $file; + } else { + return ''; + } + return make_cdash_url($diff_url); } /** Return the cgit diff URL */ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 390768f6ed..9602d050ee 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3201,7 +3201,7 @@ parameters: - message: "#^Loose comparison via \"\\!\\=\" is not allowed\\.$#" - count: 29 + count: 26 path: app/Utils/RepositoryUtils.php - @@ -3654,41 +3654,6 @@ parameters: count: 1 path: app/Utils/RepositoryUtils.php - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$blobs with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$branch with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$directory with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$file with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$projecturl with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitoriousish_diff_url\\(\\) has parameter \\$revision with no type specified\\.$#" - count: 1 - path: app/Utils/RepositoryUtils.php - - message: "#^Method App\\\\Utils\\\\RepositoryUtils\\:\\:get_gitweb2_diff_url\\(\\) has no return type specified\\.$#" count: 1