diff options
author | Justin Tobler <jtobler@gitlab.com> | 2022-10-03 21:13:41 +0300 |
---|---|---|
committer | Justin Tobler <jtobler@gitlab.com> | 2022-10-03 21:13:41 +0300 |
commit | 44f780c1293c3828e297f64c74da59a3acf9a8d4 (patch) | |
tree | 9111528caa629eda98bf0a5487b1a4b4ea98a355 | |
parent | 7397b0e1c1a4a8fc0290347da1ddf7ac11547a18 (diff) | |
parent | a7d8c5fadafb723c7d35e5d9725fed04f9bf074f (diff) |
Merge branch 'toon-license-followups' into 'master'
repository: Small fixes in FindLicense handling
See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/4851
Merged-by: Justin Tobler <jtobler@gitlab.com>
Approved-by: Pavlo Strokov <pstrokov@gitlab.com>
Approved-by: Justin Tobler <jtobler@gitlab.com>
Co-authored-by: Toon Claes <toon@gitlab.com>
-rw-r--r-- | internal/gitaly/service/repository/license.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/repository/license_test.go | 8 | ||||
-rw-r--r-- | ruby/lib/gitaly_server/repository_service.rb | 8 |
3 files changed, 15 insertions, 3 deletions
diff --git a/internal/gitaly/service/repository/license.go b/internal/gitaly/service/repository/license.go index 4d1b8fd43..2eceece15 100644 --- a/internal/gitaly/service/repository/license.go +++ b/internal/gitaly/service/repository/license.go @@ -61,7 +61,7 @@ func (s *server) FindLicense(ctx context.Context, req *gitalypb.FindLicenseReque return &gitalypb.FindLicenseResponse{ LicenseName: "Other", LicenseShortName: "other", - LicenseUrl: "http://choosealicense.com/licenses/other/", + LicenseNickname: "LICENSE", // Show as LICENSE in the UI LicensePath: repoFiler.path, }, nil } diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go index 23059844a..3f000e80e 100644 --- a/internal/gitaly/service/repository/license_test.go +++ b/internal/gitaly/service/repository/license_test.go @@ -90,8 +90,14 @@ SOFTWARE.`, }, expectedLicenseRuby: &gitalypb.FindLicenseResponse{ LicenseShortName: "other", - LicenseUrl: "http://choosealicense.com/licenses/other/", LicenseName: "Other", + LicenseNickname: "LICENSE", + LicensePath: "LICENSE.md", + }, + expectedLicenseGo: &gitalypb.FindLicenseResponse{ + LicenseShortName: "other", + LicenseName: "Other", + LicenseNickname: "LICENSE", LicensePath: "LICENSE.md", }, }, diff --git a/ruby/lib/gitaly_server/repository_service.rb b/ruby/lib/gitaly_server/repository_service.rb index 514e80723..98cb8b748 100644 --- a/ruby/lib/gitaly_server/repository_service.rb +++ b/ruby/lib/gitaly_server/repository_service.rb @@ -12,13 +12,19 @@ module GitalyServer return Gitaly::FindLicenseResponse.new(license_short_name: "") unless project&.license license = project.license + return Gitaly::FindLicenseResponse.new( license_short_name: license.key || "", license_name: license.name || "", license_url: license.url || "", license_path: project.matched_file&.filename, license_nickname: license.nickname || "" - ) + ).tap do |resp| + if license.key == "other" + resp.license_nickname = "LICENSE" + resp.license_url = "" + end + end rescue Rugged::Error end |