Skip to content

Commit a7f02a0

Browse files
committed
Fix lint
1 parent ca3e32f commit a7f02a0

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

services/repository/archiver/archiver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func ParseFileName(uri string) (ext string, tp git.ArchiveType, err error) {
8181
default:
8282
return "", 0, ErrUnknownArchiveFormat{RequestFormat: uri}
8383
}
84-
return
84+
return ext, tp, nil
8585
}
8686

8787
// NewRequest creates an archival request, based on the URI. The

services/repository/archiver/archiver_test.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"code.gitea.io/gitea/models/db"
1212
"code.gitea.io/gitea/models/unittest"
13+
"code.gitea.io/gitea/modules/git"
1314
"code.gitea.io/gitea/services/contexttest"
1415

1516
_ "code.gitea.io/gitea/models/actions"
@@ -31,47 +32,47 @@ func TestArchive_Basic(t *testing.T) {
3132
contexttest.LoadGitRepo(t, ctx)
3233
defer ctx.Repo.GitRepo.Close()
3334

34-
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
35+
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
3536
assert.NoError(t, err)
3637
assert.NotNil(t, bogusReq)
3738
assert.EqualValues(t, firstCommit+".zip", bogusReq.GetArchiveName())
3839

3940
// Check a series of bogus requests.
4041
// Step 1, valid commit with a bad extension.
41-
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".dilbert")
42+
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, 100)
4243
assert.Error(t, err)
4344
assert.Nil(t, bogusReq)
4445

4546
// Step 2, missing commit.
46-
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "dbffff.zip")
47+
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "dbffff", git.ZIP)
4748
assert.Error(t, err)
4849
assert.Nil(t, bogusReq)
4950

5051
// Step 3, doesn't look like branch/tag/commit.
51-
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "db.zip")
52+
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "db", git.ZIP)
5253
assert.Error(t, err)
5354
assert.Nil(t, bogusReq)
5455

55-
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "master.zip")
56+
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "master", git.ZIP)
5657
assert.NoError(t, err)
5758
assert.NotNil(t, bogusReq)
5859
assert.EqualValues(t, "master.zip", bogusReq.GetArchiveName())
5960

60-
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "test/archive.zip")
61+
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "test/archive", git.ZIP)
6162
assert.NoError(t, err)
6263
assert.NotNil(t, bogusReq)
6364
assert.EqualValues(t, "test-archive.zip", bogusReq.GetArchiveName())
6465

6566
// Now two valid requests, firstCommit with valid extensions.
66-
zipReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
67+
zipReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
6768
assert.NoError(t, err)
6869
assert.NotNil(t, zipReq)
6970

70-
tgzReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".tar.gz")
71+
tgzReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.TARGZ)
7172
assert.NoError(t, err)
7273
assert.NotNil(t, tgzReq)
7374

74-
secondReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, secondCommit+".zip")
75+
secondReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, secondCommit, git.ZIP)
7576
assert.NoError(t, err)
7677
assert.NotNil(t, secondReq)
7778

@@ -91,7 +92,7 @@ func TestArchive_Basic(t *testing.T) {
9192
// Sleep two seconds to make sure the queue doesn't change.
9293
time.Sleep(2 * time.Second)
9394

94-
zipReq2, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
95+
zipReq2, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
9596
assert.NoError(t, err)
9697
// This zipReq should match what's sitting in the queue, as we haven't
9798
// let it release yet. From the consumer's point of view, this looks like
@@ -106,12 +107,12 @@ func TestArchive_Basic(t *testing.T) {
106107
// Now we'll submit a request and TimedWaitForCompletion twice, before and
107108
// after we release it. We should trigger both the timeout and non-timeout
108109
// cases.
109-
timedReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, secondCommit+".tar.gz")
110+
timedReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, secondCommit, git.TARGZ)
110111
assert.NoError(t, err)
111112
assert.NotNil(t, timedReq)
112113
doArchive(db.DefaultContext, timedReq)
113114

114-
zipReq2, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
115+
zipReq2, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
115116
assert.NoError(t, err)
116117
// Now, we're guaranteed to have released the original zipReq from the queue.
117118
// Ensure that we don't get handed back the released entry somehow, but they

0 commit comments

Comments
 (0)