forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Delete related PullAutoMerge and ReviewState on User/Repo Deletion (go-gitea#19649) Allow custom default merge message with .gitea/default_merge_message/<merge_style>_TEMPLATE.md (go-gitea#18177) Allow to mark files in a PR as viewed (go-gitea#19007) Auto merge pull requests when all checks succeeded via API (go-gitea#9307) Hide private repositories in packages (go-gitea#19584) Only show accessible teams in dashboard dropdown list (go-gitea#19642) prevent double click new issue/pull/comment button (go-gitea#16157) Improve reviewing PR UX (go-gitea#19612) [skip ci] Updated translations via Crowdin Add Changelog v1.16.7 (go-gitea#19575) (go-gitea#19644) Set safe dir for git operations in .drone.yml CI (go-gitea#19641) Add missing `sorting` column in `project_issue` table (go-gitea#19635)
- Loading branch information
Showing
100 changed files
with
1,949 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ func testGit(t *testing.T, u *url.URL) { | |
|
||
t.Run("CreateAgitFlowPull", doCreateAgitFlowPull(dstPath, &httpContext, "master", "test/head")) | ||
t.Run("BranchProtectMerge", doBranchProtectPRMerge(&httpContext, dstPath)) | ||
t.Run("AutoMerge", doAutoPRMerge(&httpContext, dstPath)) | ||
t.Run("CreatePRAndSetManuallyMerged", doCreatePRAndSetManuallyMerged(httpContext, httpContext, dstPath, "master", "test-manually-merge")) | ||
t.Run("MergeFork", func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
@@ -615,6 +616,88 @@ func doBranchDelete(ctx APITestContext, owner, repo, branch string) func(*testin | |
} | ||
} | ||
|
||
func doAutoPRMerge(baseCtx *APITestContext, dstPath string) func(t *testing.T) { | ||
return func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
||
ctx := NewAPITestContext(t, baseCtx.Username, baseCtx.Reponame) | ||
|
||
t.Run("CheckoutProtected", doGitCheckoutBranch(dstPath, "protected")) | ||
t.Run("PullProtected", doGitPull(dstPath, "origin", "protected")) | ||
t.Run("GenerateCommit", func(t *testing.T) { | ||
_, err := generateCommitWithNewData(littleSize, dstPath, "[email protected]", "User Two", "branch-data-file-") | ||
assert.NoError(t, err) | ||
}) | ||
t.Run("PushToUnprotectedBranch", doGitPushTestRepository(dstPath, "origin", "protected:unprotected3")) | ||
var pr api.PullRequest | ||
var err error | ||
t.Run("CreatePullRequest", func(t *testing.T) { | ||
pr, err = doAPICreatePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, "protected", "unprotected3")(t) | ||
assert.NoError(t, err) | ||
}) | ||
|
||
// Request repository commits page | ||
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d/commits", baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
resp := ctx.Session.MakeRequest(t, req, http.StatusOK) | ||
doc := NewHTMLParser(t, resp.Body) | ||
|
||
// Get first commit URL | ||
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href") | ||
assert.True(t, exists) | ||
assert.NotEmpty(t, commitURL) | ||
|
||
commitID := path.Base(commitURL) | ||
|
||
// Call API to add Pending status for commit | ||
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, commitID, api.CommitStatusPending)) | ||
|
||
// Cancel not existing auto merge | ||
ctx.ExpectedCode = http.StatusNotFound | ||
t.Run("CancelAutoMergePR", doAPICancelAutoMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
|
||
// Add auto merge request | ||
ctx.ExpectedCode = http.StatusCreated | ||
t.Run("AutoMergePR", doAPIAutoMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
|
||
// Can not create schedule twice | ||
ctx.ExpectedCode = http.StatusConflict | ||
t.Run("AutoMergePRTwice", doAPIAutoMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
|
||
// Cancel auto merge request | ||
ctx.ExpectedCode = http.StatusNoContent | ||
t.Run("CancelAutoMergePR", doAPICancelAutoMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
|
||
// Add auto merge request | ||
ctx.ExpectedCode = http.StatusCreated | ||
t.Run("AutoMergePR", doAPIAutoMergePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)) | ||
|
||
// Check pr status | ||
ctx.ExpectedCode = 0 | ||
pr, err = doAPIGetPullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)(t) | ||
assert.NoError(t, err) | ||
assert.False(t, pr.HasMerged) | ||
|
||
// Call API to add Failure status for commit | ||
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, commitID, api.CommitStatusFailure)) | ||
|
||
// Check pr status | ||
pr, err = doAPIGetPullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)(t) | ||
assert.NoError(t, err) | ||
assert.False(t, pr.HasMerged) | ||
|
||
// Call API to add Success status for commit | ||
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, commitID, api.CommitStatusSuccess)) | ||
|
||
// wait to let gitea merge stuff | ||
time.Sleep(time.Second) | ||
|
||
// test pr status | ||
pr, err = doAPIGetPullRequest(ctx, baseCtx.Username, baseCtx.Reponame, pr.Index)(t) | ||
assert.NoError(t, err) | ||
assert.True(t, pr.HasMerged) | ||
} | ||
} | ||
|
||
func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headBranch string) func(t *testing.T) { | ||
return func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.