mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Add close and re-open of the issue.
This commit is contained in:
@@ -81,9 +81,12 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
post("/:owner/:repository/issue_comments/new", commentForm)( usersOnly { form =>
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
val action = params.get("action") filter { action =>
|
||||
updateClosed(owner, repository, form.issueId, if(action == "close") true else false) > 0
|
||||
}
|
||||
|
||||
redirect("/%s/%s/issues/%d#comment-%d".format(owner, repository, form.issueId,
|
||||
createComment(owner, repository, context.loginAccount.get.userName, form.issueId, form.content)))
|
||||
createComment(owner, repository, context.loginAccount.get.userName, form.issueId, form.content, action)))
|
||||
})
|
||||
|
||||
// TODO Authenticator, repository checking
|
||||
|
||||
@@ -185,12 +185,12 @@ trait IssuesService {
|
||||
} get
|
||||
|
||||
def createComment(owner: String, repository: String, loginUser: String,
|
||||
issueId: Int, content: String) =
|
||||
issueId: Int, content: String, action: Option[String]) =
|
||||
IssueComments.autoInc insert (
|
||||
owner,
|
||||
repository,
|
||||
issueId,
|
||||
None,
|
||||
action,
|
||||
loginUser,
|
||||
content,
|
||||
currentDate,
|
||||
@@ -213,6 +213,14 @@ trait IssuesService {
|
||||
t.content ~ t.updatedDate
|
||||
} update (content, currentDate)
|
||||
|
||||
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean) =
|
||||
Issues
|
||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
||||
.map { t =>
|
||||
t.closed ~ t.updatedDate
|
||||
}
|
||||
.update (closed, currentDate)
|
||||
|
||||
}
|
||||
|
||||
object IssuesService {
|
||||
|
||||
@@ -79,7 +79,7 @@ class CommitLogHook(owner: String, repository: String) extends PostReceiveHook
|
||||
"(^|\\W)#(\\d+)(\\W|$)".r.findAllIn(commit.fullMessage).matchData.foreach { matchData =>
|
||||
val issueId = matchData.group(2)
|
||||
if(getAccountByUserName(commit.committer).isDefined && getIssue(owner, repository, issueId).isDefined){
|
||||
createComment(owner, repository, commit.committer, issueId.toInt, commit.fullMessage)
|
||||
createComment(owner, repository, commit.committer, issueId.toInt, commit.fullMessage, None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user