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.
Don't close issues via commits on non-default branch. (go-gitea#5622)
Adds a small check to close the issues only if the referencing commits are on the default branch. Fixes: go-gitea#2314.
- Loading branch information
1 parent
9863591
commit c4e6479
Showing
2 changed files
with
63 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,10 +227,37 @@ func TestUpdateIssuesCommit(t *testing.T) { | |
|
||
AssertNotExistsBean(t, commentBean) | ||
AssertNotExistsBean(t, &Issue{RepoID: repo.ID, Index: 2}, "is_closed=1") | ||
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits)) | ||
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, repo.DefaultBranch)) | ||
AssertExistsAndLoadBean(t, commentBean) | ||
AssertExistsAndLoadBean(t, issueBean, "is_closed=1") | ||
CheckConsistencyFor(t, &Action{}) | ||
|
||
// Test that push to a non-default branch closes no issue. | ||
pushCommits = []*PushCommit{ | ||
{ | ||
Sha1: "abcdef1", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
AuthorEmail: "[email protected]", | ||
AuthorName: "User Four", | ||
Message: "close #1", | ||
}, | ||
} | ||
repo = AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository) | ||
commentBean = &Comment{ | ||
Type: CommentTypeCommitRef, | ||
CommitSHA: "abcdef1", | ||
PosterID: user.ID, | ||
IssueID: 6, | ||
} | ||
issueBean = &Issue{RepoID: repo.ID, Index: 1} | ||
|
||
AssertNotExistsBean(t, commentBean) | ||
AssertNotExistsBean(t, &Issue{RepoID: repo.ID, Index: 1}, "is_closed=1") | ||
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, "non-existing-branch")) | ||
AssertExistsAndLoadBean(t, commentBean) | ||
AssertNotExistsBean(t, issueBean, "is_closed=1") | ||
CheckConsistencyFor(t, &Action{}) | ||
} | ||
|
||
func testCorrectRepoAction(t *testing.T, opts CommitRepoActionOptions, actionBean *Action) { | ||
|