Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepositoryUtils: fix GitLab URL generation #2341

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions app/Utils/RepositoryUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
37 changes: 1 addition & 36 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ parameters:

-
message: "#^Loose comparison via \"\\!\\=\" is not allowed\\.$#"
count: 29
count: 26
path: app/Utils/RepositoryUtils.php

-
Expand Down Expand Up @@ -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
Expand Down