Skip to content
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

Add "Update Branch" button to Pull Requests #9784

Merged
merged 39 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
38a27df
add Divergence
6543 Jan 15, 2020
2c7fc31
add Update Button
6543 Jan 15, 2020
26d686f
first working version
6543 Jan 16, 2020
d8522ac
re-use code
6543 Jan 16, 2020
efe6982
split raw merge commands and db-change functions (notify, cache, ...)
6543 Jan 16, 2020
328ecc3
use rawMerge (remove redundant code)
6543 Jan 16, 2020
9249d47
own function to get Diverging of PRs
6543 Jan 16, 2020
454ee44
use FlashError
6543 Jan 16, 2020
5d5d919
correct Error Msg
6543 Jan 16, 2020
3c6157b
hook is triggerd ... so remove comment
6543 Jan 16, 2020
88fa4c5
add "branch2" to "user2/repo1" because it unit-test "TestPullView_Rev…
6543 Jan 16, 2020
7776738
move GetPerm to IsUserAllowedToUpdate
6543 Jan 16, 2020
e3adbd2
add Flash Success MSG
6543 Jan 16, 2020
05c0c1b
imprufe code
6543 Jan 16, 2020
f7d924a
fix-lint
6543 Jan 16, 2020
e2f96d9
TEST: add PullRequest ID:5
6543 Jan 16, 2020
8bad5d2
correct comments
6543 Jan 16, 2020
7442991
Merge branch 'master' into update-pr
6543 Jan 16, 2020
143d8e8
make PR5 outdated
6543 Jan 16, 2020
fb33b4b
fix Tests
6543 Jan 16, 2020
069a393
WIP: add pull update test
6543 Jan 16, 2020
720fbf1
update revs
6543 Jan 16, 2020
892ddd9
update locales
6543 Jan 16, 2020
7aa9e84
working TEST
6543 Jan 16, 2020
7502ff5
Merge branch 'master' into update-pr
6543 Jan 16, 2020
36a34cd
update UI
6543 Jan 16, 2020
18fadef
misspell
6543 Jan 16, 2020
97e51ec
change style
6543 Jan 16, 2020
18eb495
add 1s delay so rev exist
6543 Jan 16, 2020
2b58961
move row up (before merge row)
6543 Jan 16, 2020
688a53a
fix lint nit
6543 Jan 16, 2020
97a6f83
UI remove divider
6543 Jan 16, 2020
32c5eee
Merge branch 'master' into update-pr
6543 Jan 16, 2020
6400bcc
Update style
lafriks Jan 17, 2020
fa4779b
nits
6543 Jan 17, 2020
fbbc7f4
do it right
6543 Jan 17, 2020
717406e
introduce IsSameRepo
6543 Jan 17, 2020
f26c8b3
remove useless check
6543 Jan 17, 2020
246748f
Merge branch 'master' into update-pr
6543 Jan 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TEST: add PullRequest ID:5
Repo: user2/repo1
Base: branch1
Head: pr-to-update
  • Loading branch information
6543 committed Jan 16, 2020
commit e2f96d945d318770234091fd3b5e3f9e40bd0f51
6 changes: 3 additions & 3 deletions integrations/api_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ func TestAPISearchIssue(t *testing.T) {
var apiIssues []*api.Issue
DecodeJSON(t, resp, &apiIssues)

assert.Len(t, apiIssues, 8)
assert.Len(t, apiIssues, 9)

query := url.Values{}
query.Add("token", token)
link.RawQuery = query.Encode()
req = NewRequest(t, "GET", link.String())
resp = session.MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
assert.Len(t, apiIssues, 8)
assert.Len(t, apiIssues, 9)

query.Add("state", "closed")
link.RawQuery = query.Encode()
Expand All @@ -163,5 +163,5 @@ func TestAPISearchIssue(t *testing.T) {
req = NewRequest(t, "GET", link.String())
resp = session.MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
assert.Len(t, apiIssues, 0)
assert.Len(t, apiIssues, 1)
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5c050d3b6d2db231ab1f64e324f1b6b9a0b181c2
985f0301dba5e7b34be866819cd15ad3d8f508ee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5c050d3b6d2db231ab1f64e324f1b6b9a0b181c2
4 changes: 2 additions & 2 deletions integrations/repo_activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func TestRepoActivity(t *testing.T) {
list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc")
assert.Len(t, list.Nodes, 1)

// Should be 2 merged proposed pull requests
// Should be 3 merged proposed pull requests
list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc")
assert.Len(t, list.Nodes, 2)
assert.Len(t, list.Nodes, 3)

// Should be 3 new issues
list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
Expand Down
12 changes: 12 additions & 0 deletions models/fixtures/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,15 @@
created_unix: 946684830
updated_unix: 999307200
deadline_unix: 1019307200

-
id: 11
repo_id: 1
index: 5
poster_id: 1
name: pull5
content: content for the a pull request
is_closed: false
is_pull: true
created_unix: 1579194806
updated_unix: 1579194806
15 changes: 14 additions & 1 deletion models/fixtures/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@
head_branch: branch1
base_branch: master
merge_base: abcdef1234567890
has_merged: false
has_merged: false

-
id: 5 # this PR is outdated (one commit behind branch1 )
type: 0 # gitea pull request
status: 2 # mergable
issue_id: 11
index: 5
head_repo_id: 1
base_repo_id: 1
head_branch: pr-to-update
base_branch: branch1
merge_base: 1234567890abcdef
has_merged: false
2 changes: 1 addition & 1 deletion models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
is_private: false
num_issues: 2
num_closed_issues: 1
num_pulls: 2
num_pulls: 3
num_closed_pulls: 0
num_milestones: 3
num_closed_milestones: 1
Expand Down
8 changes: 4 additions & 4 deletions models/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ func TestIssue_SearchIssueIDsByKeyword(t *testing.T) {

total, ids, err = SearchIssueIDsByKeyword("for", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 4, total)
assert.EqualValues(t, []int64{1, 2, 3, 5}, ids)
assert.EqualValues(t, 5, total)
assert.EqualValues(t, []int64{1, 2, 3, 5, 11}, ids)

// issue1's comment id 2
total, ids, err = SearchIssueIDsByKeyword("good", []int64{1}, 10, 0)
Expand Down Expand Up @@ -305,8 +305,8 @@ func testInsertIssue(t *testing.T, title, content string) {
assert.True(t, has)
assert.EqualValues(t, issue.Title, newIssue.Title)
assert.EqualValues(t, issue.Content, newIssue.Content)
// there are 4 issues and max index is 4 on repository 1, so this one should 5
assert.EqualValues(t, 5, newIssue.Index)
// there are 5 issues and max index is 5 on repository 1, so this one should 6
assert.EqualValues(t, 6, newIssue.Index)

_, err = x.ID(issue.ID).Delete(new(Issue))
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion models/issue_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Test_newIssueUsers(t *testing.T) {
newIssue := &Issue{
RepoID: repo.ID,
PosterID: 4,
Index: 5,
Index: 6,
Title: "newTestIssueTitle",
Content: "newTestIssueContent",
}
Expand Down
18 changes: 10 additions & 8 deletions models/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ func TestPullRequestsNewest(t *testing.T) {
Labels: []string{},
})
assert.NoError(t, err)
assert.Equal(t, int64(2), count)
if assert.Len(t, prs, 2) {
assert.Equal(t, int64(2), prs[0].ID)
assert.Equal(t, int64(1), prs[1].ID)
assert.EqualValues(t, 3, count)
if assert.Len(t, prs, 3) {
assert.EqualValues(t, 5, prs[0].ID)
assert.EqualValues(t, 2, prs[1].ID)
assert.EqualValues(t, 1, prs[2].ID)
}
}

Expand All @@ -77,10 +78,11 @@ func TestPullRequestsOldest(t *testing.T) {
Labels: []string{},
})
assert.NoError(t, err)
assert.Equal(t, int64(2), count)
if assert.Len(t, prs, 2) {
assert.Equal(t, int64(1), prs[0].ID)
assert.Equal(t, int64(2), prs[1].ID)
assert.EqualValues(t, 3, count)
if assert.Len(t, prs, 3) {
assert.EqualValues(t, 1, prs[0].ID)
assert.EqualValues(t, 2, prs[1].ID)
assert.EqualValues(t, 5, prs[2].ID)
}
}

Expand Down