@@ -227,10 +227,37 @@ func TestUpdateIssuesCommit(t *testing.T) {
227
227
228
228
AssertNotExistsBean (t , commentBean )
229
229
AssertNotExistsBean (t , & Issue {RepoID : repo .ID , Index : 2 }, "is_closed=1" )
230
- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits ))
230
+ assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , repo . DefaultBranch ))
231
231
AssertExistsAndLoadBean (t , commentBean )
232
232
AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
233
233
CheckConsistencyFor (t , & Action {})
234
+
235
+ // Test that push to a non-default branch closes no issue.
236
+ pushCommits = []* PushCommit {
237
+ {
238
+ Sha1 : "abcdef1" ,
239
+ CommitterEmail :
"[email protected] " ,
240
+ CommitterName : "User Two" ,
241
+
242
+ AuthorName : "User Four" ,
243
+ Message : "close #1" ,
244
+ },
245
+ }
246
+ repo = AssertExistsAndLoadBean (t , & Repository {ID : 3 }).(* Repository )
247
+ commentBean = & Comment {
248
+ Type : CommentTypeCommitRef ,
249
+ CommitSHA : "abcdef1" ,
250
+ PosterID : user .ID ,
251
+ IssueID : 6 ,
252
+ }
253
+ issueBean = & Issue {RepoID : repo .ID , Index : 1 }
254
+
255
+ AssertNotExistsBean (t , commentBean )
256
+ AssertNotExistsBean (t , & Issue {RepoID : repo .ID , Index : 1 }, "is_closed=1" )
257
+ assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , "non-existing-branch" ))
258
+ AssertExistsAndLoadBean (t , commentBean )
259
+ AssertNotExistsBean (t , issueBean , "is_closed=1" )
260
+ CheckConsistencyFor (t , & Action {})
234
261
}
235
262
236
263
func testCorrectRepoAction (t * testing.T , opts CommitRepoActionOptions , actionBean * Action ) {
0 commit comments