summaryrefslogtreecommitdiffstats
path: root/integrations/git_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-21 18:18:13 +0000
committerGitHub <noreply@github.com>2020-02-21 18:18:13 +0000
commitcadec9bc22624a5a5c3fa006304704f24cda65f3 (patch)
tree95b1d4d12028e5d3ea3c729db9a9eda9ffc15753 /integrations/git_test.go
parentcfcd8e41467dd17c13c2ef80a6f12ae883f1f9f3 (diff)
downloadgitea-cadec9bc22624a5a5c3fa006304704f24cda65f3.tar.gz
gitea-cadec9bc22624a5a5c3fa006304704f24cda65f3.zip
Prevent panic on merge to PR (#10403)
If you attempt to merge to a branch which on a PR there will be a nil pointer error in the pull request checker. This panic is uncaught and will bring down the gitea server. This PR adds protection to prevent this.
Diffstat (limited to 'integrations/git_test.go')
-rw-r--r--integrations/git_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/integrations/git_test.go b/integrations/git_test.go
index 7753b2cb72..8e02bc4db9 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -351,6 +351,17 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
pr, err = doAPICreatePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, "protected", "unprotected")(t)
assert.NoError(t, err)
})
+ t.Run("GenerateCommit", func(t *testing.T) {
+ _, err := generateCommitWithNewData(littleSize, dstPath, "user2@example.com", "User Two", "branch-data-file-")
+ assert.NoError(t, err)
+ })
+ t.Run("PushToUnprotectedBranch", doGitPushTestRepository(dstPath, "origin", "protected:unprotected-2"))
+ var pr2 api.PullRequest
+ t.Run("CreatePullRequest", func(t *testing.T) {
+ pr2, err = doAPICreatePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, "unprotected", "unprotected-2")(t)
+ assert.NoError(t, err)
+ })
+ t.Run("MergePR2", doAPIMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr2.Index))
t.Run("MergePR", doAPIMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index))
t.Run("PullProtected", doGitPull(dstPath, "origin", "protected"))
t.Run("ProtectProtectedBranchWhitelist", doProtectBranch(ctx, "protected", baseCtx.Username))