-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add API to get commits of PR #16300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
6543
merged 5 commits into
go-gitea:main
from
sebastian-sauer:feature/10918_commits_of_pr
Jul 2, 2021
Merged
Add API to get commits of PR #16300
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8e06bb5
Add API to get commits of PR
sebastian-sauer 8ae97b6
Merge remote-tracking branch 'origin/main' into feature/10918_commits…
sebastian-sauer 0cc2fba
Use X-Total-Count header instead of X-Total
sebastian-sauer 419a2a9
Merge branch 'main' into feature/10918_commits_of_pr
6543 77f92b3
Merge branch 'main' into feature/10918_commits_of_pr
6543 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
api "code.gitea.io/gitea/modules/structs" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAPIPullCommits(t *testing.T) { | ||
defer prepareTestEnv(t)() | ||
pullIssue := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) | ||
assert.NoError(t, pullIssue.LoadIssue()) | ||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: pullIssue.HeadRepoID}).(*models.Repository) | ||
|
||
session := loginUser(t, "user2") | ||
req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/commits", repo.OwnerName, repo.Name, pullIssue.Index) | ||
resp := session.MakeRequest(t, req, http.StatusOK) | ||
|
||
var commits []*api.Commit | ||
DecodeJSON(t, resp, &commits) | ||
|
||
if !assert.Len(t, commits, 2) { | ||
return | ||
} | ||
|
||
assert.Equal(t, "5f22f7d0d95d614d25a5b68592adb345a4b5c7fd", commits[0].SHA) | ||
assert.Equal(t, "4a357436d925b5c974181ff12a994538ddc5a269", commits[1].SHA) | ||
} | ||
|
||
// TODO add tests for already merged PR and closed PR |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.