Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/gitaly/service/repository/license.go4
-rw-r--r--internal/gitaly/service/repository/license_test.go23
2 files changed, 20 insertions, 7 deletions
diff --git a/internal/gitaly/service/repository/license.go b/internal/gitaly/service/repository/license.go
index ee5f19d13..a3d2fb4f1 100644
--- a/internal/gitaly/service/repository/license.go
+++ b/internal/gitaly/service/repository/license.go
@@ -22,10 +22,6 @@ import (
func (s *server) FindLicense(ctx context.Context, req *gitalypb.FindLicenseRequest) (*gitalypb.FindLicenseResponse, error) {
if featureflag.GoFindLicense.IsEnabled(ctx) {
- if req.GetRepository() == nil {
- return &gitalypb.FindLicenseResponse{}, nil
- }
-
repo := localrepo.New(s.gitCmdFactory, s.catfileCache, req.GetRepository(), s.cfg)
hasHeadRevision, err := repo.HasRevision(ctx, "HEAD")
diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go
index cd5612c98..5b50bcccc 100644
--- a/internal/gitaly/service/repository/license_test.go
+++ b/internal/gitaly/service/repository/license_test.go
@@ -21,11 +21,18 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, rubySrv *rub
featureflag.GoFindLicense,
}).Run(t, func(t *testing.T, ctx context.Context) {
for _, tc := range []struct {
- desc string
- files map[string]string
- expectedLicense string
+ desc string
+ nonExistentRepository bool
+ files map[string]string
+ expectedLicense string
+ errorContains string
}{
{
+ desc: "repository does not exist",
+ nonExistentRepository: true,
+ errorContains: "rpc error: code = NotFound desc = GetRepoPath: not a git repository",
+ },
+ {
desc: "empty if no license file in repo",
files: map[string]string{
"README.md": "readme content",
@@ -83,7 +90,17 @@ SOFTWARE.`},
gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("master"), gittest.WithTreeEntries(treeEntries...), gittest.WithParents())
+ if tc.nonExistentRepository {
+ clean()
+ }
+
resp, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: repo})
+ if tc.errorContains != "" {
+ require.Error(t, err)
+ require.Contains(t, err.Error(), tc.errorContains)
+ return
+ }
+
require.NoError(t, err)
testassert.ProtoEqual(t, &gitalypb.FindLicenseResponse{
LicenseShortName: tc.expectedLicense,