Skip to content

Commit

Permalink
RepositoryUtils: fix GitLab URL generation
Browse files Browse the repository at this point in the history
GitLab started using a `/-/` component to act as a separator between
project paths and project resources.
  • Loading branch information
mathstuf committed Jul 16, 2024
1 parent cd9b934 commit 8974247
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/Utils/RepositoryUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,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/' . $branch . '/';
if ($directory != '') {
$diff_url .= $directory . '/';
}
$diff_url .= $file;
} else {
return '';
}
return make_cdash_url($diff_url);
}

/** Return the cgit diff URL */
Expand Down

0 comments on commit 8974247

Please sign in to comment.