From 75585dec3c204eb79a23b9025fb6c63fe631c57b Mon Sep 17 00:00:00 2001 From: DmitryFrolovTri <23313323+DmitryFrolovTri@users.noreply.github.com> Date: Tue, 15 Nov 2022 15:32:58 +0000 Subject: [PATCH] lint related changes --- routers/private/hook_pre_receive.go | 10 +++++----- tests/integration/git_test.go | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index 1def817208..eb18da8a4d 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -132,16 +132,16 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) { newCommitID := opts.NewCommitIDs[i] refFullName := opts.RefFullNames[i] - //Check size - if newCommitID != git.EmptySHA && repo.RepoSizeIsOversized(pushSize.Size) { //Check next size if we are not deleting a reference + // Check size + if newCommitID != git.EmptySHA && repo.RepoSizeIsOversized(pushSize.Size) { // Check next size if we are not deleting a reference log.Warn("Forbidden: new repo size is over limitation: %d", repo.SizeLimit) ctx.JSON(http.StatusForbidden, map[string]interface{}{ "err": fmt.Sprintf("new repo size is over limitation: %d", repo.SizeLimit), }) } - //TODO investigate why on force push some git objects are not cleaned on server side. - //TODO corner-case force push and branch creation -> git.EmptySHA == oldCommitID - //TODO calculate pushed LFS objects size + // TODO investigate why on force push some git objects are not cleaned on server side. + // TODO corner-case force push and branch creation -> git.EmptySHA == oldCommitID + // TODO calculate pushed LFS objects size switch { case strings.HasPrefix(refFullName, git.BranchPrefix): diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go index 33c74b2aed..0314f2913a 100644 --- a/tests/integration/git_test.go +++ b/tests/integration/git_test.go @@ -79,29 +79,29 @@ func testGit(t *testing.T, u *url.URL) { t.Run("SizeLimit", func(t *testing.T) { t.Run("Under", func(t *testing.T) { - PrintCurrentTest(t) + tests.PrintCurrentTest(t) doCommitAndPush(t, littleSize, dstPath, "data-file-") }) t.Run("Over", func(t *testing.T) { - PrintCurrentTest(t) + tests.PrintCurrentTest(t) doAPISetRepoSizeLimit(forkedUserCtx, forkedUserCtx.Username, forkedUserCtx.Reponame, littleSize) doCommitAndPushWithExpectedError(t, bigSize, dstPath, "data-file-") }) t.Run("UnderAfterResize", func(t *testing.T) { - PrintCurrentTest(t) + tests.PrintCurrentTest(t) doAPISetRepoSizeLimit(forkedUserCtx, forkedUserCtx.Username, forkedUserCtx.Reponame, bigSize*10) doCommitAndPush(t, littleSize, dstPath, "data-file-") }) t.Run("Deletion", func(t *testing.T) { - PrintCurrentTest(t) - //TODO doDeleteCommitAndPush(t, littleSize, dstPath, "data-file-") + tests.PrintCurrentTest(t) + // TODO doDeleteCommitAndPush(t, littleSize, dstPath, "data-file-") }) - //TODO delete branch - //TODO delete tag - //TODO add big commit that will be over with the push - //TODO add lfs - //TODO remove lfs - //TODO add missing case + // TODO delete branch + // TODO delete tag + // TODO add big commit that will be over with the push + // TODO add lfs + // TODO remove lfs + // TODO add missing case }) t.Run("CreateAgitFlowPull", doCreateAgitFlowPull(dstPath, &httpContext, "master", "test/head")) t.Run("BranchProtectMerge", doBranchProtectPRMerge(&httpContext, dstPath)) @@ -324,7 +324,7 @@ func doCommitAndPush(t *testing.T, size int, repoPath, prefix string) string { func doCommitAndPushWithExpectedError(t *testing.T, size int, repoPath, prefix string) string { name, err := generateCommitWithNewData(size, repoPath, "user2@example.com", "User Two", prefix) assert.NoError(t, err) - _, err = git.NewCommand("push", "origin", "master").RunInDir(repoPath) //Push + _, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "master").RunStdString(&git.RunOpts{Dir: repoPath}) // Push assert.Error(t, err) return name }