mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-16 14:47:48 +02:00
lint-go fixes
This commit is contained in:
parent
ca9489a137
commit
baafa7b65b
@ -361,15 +361,6 @@ func loadObjectsSizesViaBatch(ctx *gitea_context.PrivateContext, repoPath string
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseSize parses the object size from a string
|
||||
func parseSize(sizeStr string) (int64, error) {
|
||||
size, err := strconv.ParseInt(sizeStr, 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to parse object size: %w", err)
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
||||
/*
|
||||
LFS pointer scanning (fast-ish, bounded)
|
||||
|
||||
|
||||
@ -136,23 +136,6 @@ func doAPIForkRepository(ctx APITestContext, username string, callback ...func(*
|
||||
}
|
||||
}
|
||||
|
||||
func doAPIGetRepositorySize(ctx APITestContext, owner, repo string) func(*testing.T) int64 {
|
||||
return func(t *testing.T) int64 {
|
||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s", ctx.Username, ctx.Reponame)
|
||||
|
||||
req := NewRequest(t, "GET", urlStr).
|
||||
AddTokenAuth(ctx.Token)
|
||||
if ctx.ExpectedCode != 0 {
|
||||
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
|
||||
}
|
||||
resp := ctx.Session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var repository api.Repository
|
||||
DecodeJSON(t, resp, &repository)
|
||||
return int64(repository.Size)
|
||||
}
|
||||
}
|
||||
|
||||
func doAPIGetRepository(ctx APITestContext, callback ...func(*testing.T, api.Repository)) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s", ctx.Username, ctx.Reponame)).
|
||||
|
||||
@ -320,50 +320,6 @@ func lockFileTest(t *testing.T, filename, repoPath string) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func doGetRemoteRepoSizeViaAPI(t *testing.T, ctx APITestContext) int64 {
|
||||
return doAPIGetRepositorySize(ctx, ctx.Username, ctx.Reponame)(t)
|
||||
}
|
||||
|
||||
func doDeleteAndPush(t *testing.T, repoPath, filename string) {
|
||||
_, _, err := gitcmd.NewCommand("rm").AddDashesAndList(filename).WithDir(repoPath).RunStdString(t.Context()) // Delete
|
||||
assert.NoError(t, err)
|
||||
signature := git.Signature{
|
||||
Email: "user2@example.com",
|
||||
Name: "User Two",
|
||||
When: time.Now(),
|
||||
}
|
||||
_, _, err = gitcmd.NewCommand("status").WithDir(repoPath).RunStdString(t.Context())
|
||||
assert.NoError(t, err)
|
||||
err2 := git.CommitChanges(t.Context(), repoPath, git.CommitChangesOptions{ // Commit
|
||||
Committer: &signature,
|
||||
Author: &signature,
|
||||
Message: "Delete Commit",
|
||||
})
|
||||
assert.NoError(t, err2)
|
||||
_, _, err = gitcmd.NewCommand("status").WithDir(repoPath).RunStdString(t.Context())
|
||||
assert.NoError(t, err)
|
||||
_, _, err = gitcmd.NewCommand("push", "origin", "master").WithDir(repoPath).RunStdString(t.Context()) // Push
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func doGetAddCommitID(t *testing.T, repoPath, filename string) string {
|
||||
output, _, err := gitcmd.NewCommand("log", "origin", "master").WithDir(repoPath).RunStdString(t.Context()) // Push
|
||||
assert.NoError(t, err)
|
||||
list := strings.Fields(output)
|
||||
assert.LessOrEqual(t, 2, len(list))
|
||||
return list[1]
|
||||
}
|
||||
|
||||
func doRebaseCommitAndPush(t *testing.T, repoPath, commitID string) {
|
||||
command := gitcmd.NewCommand("rebase", "--interactive").AddDashesAndList(commitID)
|
||||
env := os.Environ()
|
||||
env = append(env, "GIT_SEQUENCE_EDITOR=true")
|
||||
_, _, err := command.WithDir(repoPath).WithEnv(env).RunStdString(t.Context()) // Push
|
||||
assert.NoError(t, err)
|
||||
_, _, err = gitcmd.NewCommand("push", "origin", "master", "-f").WithDir(repoPath).RunStdString(t.Context()) // Push
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func doCommitAndPush(t *testing.T, size int, repoPath, prefix string) string {
|
||||
name, err := generateCommitWithNewData(t.Context(), size, repoPath, "user2@example.com", "User Two", prefix)
|
||||
assert.NoError(t, err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user