-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add option to close issues via commit on a non master branch #5992
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
lafriks
merged 11 commits into
go-gitea:master
from
adelowo:add_option_to_close_issues_via_commit_on_a_non_master_branch
Feb 10, 2019
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d7db4f5
fixes #5957
adelowo 85a60e3
add tests to make sure config option is respected
adelowo 9758ab3
use already defined struct
adelowo 9a8b992
- use migration to make the flag repo wide not for the entire gitea i…
adelowo 4d61bef
use global config only when creating a new repository
adelowo 98b92a1
allow repo admin toggle feature via UI
adelowo 7cb3398
fix typo and improve testcase
adelowo 03c8808
fix fixtures
adelowo 958021f
fix merge conflicts
adelowo 8620f5f
add DEFAULT prefix to config value
adelowo acad54e
fix test
adelowo 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
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 |
---|---|---|
|
@@ -260,6 +260,40 @@ func TestUpdateIssuesCommit(t *testing.T) { | |
CheckConsistencyFor(t, &Action{}) | ||
} | ||
|
||
func TestUpdateIssuesCommit_Issue5957(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
|
||
// Test that push to a non-default branch closes an issue. | ||
pushCommits := []*PushCommit{ | ||
{ | ||
Sha1: "abcdef1", | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "User Two", | ||
AuthorEmail: "[email protected]", | ||
AuthorName: "User Four", | ||
Message: "close #2", | ||
}, | ||
} | ||
|
||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository) | ||
commentBean := &Comment{ | ||
Type: CommentTypeCommitRef, | ||
CommitSHA: "abcdef1", | ||
PosterID: user.ID, | ||
IssueID: 7, | ||
} | ||
|
||
issueBean := &Issue{RepoID: repo.ID, Index: 2, ID: 7} | ||
|
||
AssertNotExistsBean(t, commentBean) | ||
AssertNotExistsBean(t, issueBean, "is_closed=1") | ||
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, "non-existing-branch")) | ||
AssertExistsAndLoadBean(t, commentBean) | ||
AssertExistsAndLoadBean(t, issueBean, "is_closed=1") | ||
CheckConsistencyFor(t, &Action{}) | ||
} | ||
|
||
func testCorrectRepoAction(t *testing.T, opts CommitRepoActionOptions, actionBean *Action) { | ||
AssertNotExistsBean(t, actionBean) | ||
assert.NoError(t, CommitRepoAction(opts)) | ||
|
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
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,27 @@ | ||
// Copyright 2019 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 migrations | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"github.com/go-xorm/xorm" | ||
) | ||
|
||
func addCanCloseIssuesViaCommitInAnyBranch(x *xorm.Engine) error { | ||
|
||
type Repository struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
CloseIssuesViaCommitInAnyBranch bool `xorm:"NOT NULL DEFAULT false"` | ||
} | ||
|
||
if err := x.Sync2(new(Repository)); err != nil { | ||
return err | ||
} | ||
|
||
_, err := x.Exec("UPDATE repository SET close_issues_via_commit_in_any_branch = ?", | ||
setting.Repository.CloseIssuesViaCommitsInAnyBranch) | ||
return err | ||
} |
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
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.