-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add file status on API #7671
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
Merged
Add file status on API #7671
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3dd913a
add file status on API
lunny ac7d92b
fix tests
lunny 5310738
fix tests
lunny 6165d63
fix tests
lunny 879e705
Merge branch 'master' into lunny/add_commit_file_status2
lunny 96284b4
Merge branch 'master' into lunny/add_commit_file_status2
techknowlogick 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
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 |
---|---|---|
|
@@ -85,42 +85,69 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) { | |
pushCommits := NewPushCommits() | ||
pushCommits.Commits = []*PushCommit{ | ||
{ | ||
Sha1: "abcdef1", | ||
Sha1: "69554a6", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
AuthorEmail: "user4@example.com", | ||
AuthorName: "User Four", | ||
Message: "message1", | ||
CommitterName: "User2", | ||
AuthorEmail: "user2@example.com", | ||
AuthorName: "User2", | ||
Message: "not signed commit", | ||
}, | ||
{ | ||
Sha1: "abcdef2", | ||
Sha1: "27566bd", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
CommitterName: "User2", | ||
AuthorEmail: "[email protected]", | ||
AuthorName: "User Two", | ||
Message: "message2", | ||
AuthorName: "User2", | ||
Message: "good signed commit (with not yet validated email)", | ||
}, | ||
{ | ||
Sha1: "5099b81", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User2", | ||
AuthorEmail: "[email protected]", | ||
AuthorName: "User2", | ||
Message: "good signed commit", | ||
}, | ||
} | ||
pushCommits.Len = len(pushCommits.Commits) | ||
|
||
payloadCommits := pushCommits.ToAPIPayloadCommits("/username/reponame") | ||
if assert.Len(t, payloadCommits, 2) { | ||
assert.Equal(t, "abcdef1", payloadCommits[0].ID) | ||
assert.Equal(t, "message1", payloadCommits[0].Message) | ||
assert.Equal(t, "/username/reponame/commit/abcdef1", payloadCommits[0].URL) | ||
assert.Equal(t, "User Two", payloadCommits[0].Committer.Name) | ||
assert.Equal(t, "user2", payloadCommits[0].Committer.UserName) | ||
assert.Equal(t, "User Four", payloadCommits[0].Author.Name) | ||
assert.Equal(t, "user4", payloadCommits[0].Author.UserName) | ||
|
||
assert.Equal(t, "abcdef2", payloadCommits[1].ID) | ||
assert.Equal(t, "message2", payloadCommits[1].Message) | ||
assert.Equal(t, "/username/reponame/commit/abcdef2", payloadCommits[1].URL) | ||
assert.Equal(t, "User Two", payloadCommits[1].Committer.Name) | ||
assert.Equal(t, "user2", payloadCommits[1].Committer.UserName) | ||
assert.Equal(t, "User Two", payloadCommits[1].Author.Name) | ||
assert.Equal(t, "user2", payloadCommits[1].Author.UserName) | ||
} | ||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 16}).(*Repository) | ||
payloadCommits, err := pushCommits.ToAPIPayloadCommits(repo.RepoPath(), "/user2/repo16") | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, 3, len(payloadCommits)) | ||
|
||
assert.Equal(t, "69554a6", payloadCommits[0].ID) | ||
assert.Equal(t, "not signed commit", payloadCommits[0].Message) | ||
assert.Equal(t, "/user2/repo16/commit/69554a6", payloadCommits[0].URL) | ||
assert.Equal(t, "User2", payloadCommits[0].Committer.Name) | ||
assert.Equal(t, "user2", payloadCommits[0].Committer.UserName) | ||
assert.Equal(t, "User2", payloadCommits[0].Author.Name) | ||
assert.Equal(t, "user2", payloadCommits[0].Author.UserName) | ||
assert.EqualValues(t, []string{}, payloadCommits[0].Added) | ||
assert.EqualValues(t, []string{}, payloadCommits[0].Removed) | ||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[0].Modified) | ||
|
||
assert.Equal(t, "27566bd", payloadCommits[1].ID) | ||
assert.Equal(t, "good signed commit (with not yet validated email)", payloadCommits[1].Message) | ||
assert.Equal(t, "/user2/repo16/commit/27566bd", payloadCommits[1].URL) | ||
assert.Equal(t, "User2", payloadCommits[1].Committer.Name) | ||
assert.Equal(t, "user2", payloadCommits[1].Committer.UserName) | ||
assert.Equal(t, "User2", payloadCommits[1].Author.Name) | ||
assert.Equal(t, "user2", payloadCommits[1].Author.UserName) | ||
assert.EqualValues(t, []string{}, payloadCommits[1].Added) | ||
assert.EqualValues(t, []string{}, payloadCommits[1].Removed) | ||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[1].Modified) | ||
|
||
assert.Equal(t, "5099b81", payloadCommits[2].ID) | ||
assert.Equal(t, "good signed commit", payloadCommits[2].Message) | ||
assert.Equal(t, "/user2/repo16/commit/5099b81", payloadCommits[2].URL) | ||
assert.Equal(t, "User2", payloadCommits[2].Committer.Name) | ||
assert.Equal(t, "user2", payloadCommits[2].Committer.UserName) | ||
assert.Equal(t, "User2", payloadCommits[2].Author.Name) | ||
assert.Equal(t, "user2", payloadCommits[2].Author.UserName) | ||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[2].Added) | ||
assert.EqualValues(t, []string{}, payloadCommits[2].Removed) | ||
assert.EqualValues(t, []string{}, payloadCommits[2].Modified) | ||
} | ||
|
||
func TestPushCommits_AvatarLink(t *testing.T) { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,28 +29,28 @@ func TestCommitRepoAction(t *testing.T) { | |
}{ | ||
{ | ||
userID: 2, | ||
repositoryID: 2, | ||
repositoryID: 16, | ||
commitRepoActionOptions: CommitRepoActionOptions{ | ||
RefFullName: "refName", | ||
OldCommitID: "oldCommitID", | ||
NewCommitID: "newCommitID", | ||
Commits: &models.PushCommits{ | ||
Commits: []*models.PushCommit{ | ||
{ | ||
Sha1: "abcdef1", | ||
Sha1: "69554a6", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
AuthorEmail: "user4@example.com", | ||
AuthorName: "User Four", | ||
Message: "message1", | ||
CommitterName: "User2", | ||
AuthorEmail: "user2@example.com", | ||
AuthorName: "User2", | ||
Message: "not signed commit", | ||
}, | ||
{ | ||
Sha1: "abcdef2", | ||
Sha1: "27566bd", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
CommitterName: "User2", | ||
AuthorEmail: "[email protected]", | ||
AuthorName: "User Two", | ||
Message: "message2", | ||
AuthorName: "User2", | ||
Message: "good signed commit (with not yet validated email)", | ||
}, | ||
}, | ||
Len: 2, | ||
|
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.