mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
(refs #2)Add flag for identifying whether it's a pull request.
This commit is contained in:
@@ -18,3 +18,5 @@ CREATE TABLE PULL_REQUEST(
|
|||||||
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
||||||
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
||||||
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_FK1 FOREIGN KEY (REQUEST_USER_NAME, REQUEST_REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_FK1 FOREIGN KEY (REQUEST_USER_NAME, REQUEST_REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
||||||
|
|
||||||
|
ALTER TABLE ISSUE ADD COLUMN PULL_REQUEST BOOLEAN NOT NULL DEFAULT FALSE;
|
||||||
|
|||||||
@@ -262,23 +262,25 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
val loginUserName = context.loginAccount.get.userName
|
val loginUserName = context.loginAccount.get.userName
|
||||||
|
|
||||||
val issueId = createIssue(
|
val issueId = createIssue(
|
||||||
repository.owner,
|
owner = repository.owner,
|
||||||
repository.name,
|
repository = repository.name,
|
||||||
loginUserName,
|
loginUser = loginUserName,
|
||||||
form.title,
|
title = form.title,
|
||||||
form.content,
|
content = form.content,
|
||||||
None, None)
|
assignedUserName = None,
|
||||||
|
milestoneId = None,
|
||||||
|
isPullRequest = true)
|
||||||
|
|
||||||
createPullRequest(
|
createPullRequest(
|
||||||
repository.owner,
|
originUserName = repository.owner,
|
||||||
repository.name,
|
originRepositoryName = repository.name,
|
||||||
issueId,
|
issueId = issueId,
|
||||||
form.targetBranch,
|
originBranch = form.targetBranch,
|
||||||
form.requestUserName,
|
requestUserName = form.requestUserName,
|
||||||
repository.name,
|
requestRepositoryName = repository.name,
|
||||||
form.requestBranch,
|
requestBranch = form.requestBranch,
|
||||||
form.commitIdFrom,
|
commitIdFrom = form.commitIdFrom,
|
||||||
form.commitIdTo)
|
commitIdTo = form.commitIdTo)
|
||||||
|
|
||||||
// fetch requested branch
|
// fetch requested branch
|
||||||
JGitUtil.withGit(getRepositoryDir(repository.owner, repository.name)){ git =>
|
JGitUtil.withGit(getRepositoryDir(repository.owner, repository.name)){ git =>
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ object Issues extends Table[Issue]("ISSUE") with IssueTemplate with MilestoneTem
|
|||||||
def closed = column[Boolean]("CLOSED")
|
def closed = column[Boolean]("CLOSED")
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
|
def pullRequest = column[Boolean]("PULL_REQUEST")
|
||||||
|
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate ~ pullRequest <> (Issue, Issue.unapply _)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
||||||
}
|
}
|
||||||
@@ -36,4 +37,5 @@ case class Issue(
|
|||||||
content: Option[String],
|
content: Option[String],
|
||||||
closed: Boolean,
|
closed: Boolean,
|
||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date)
|
updatedDate: java.util.Date,
|
||||||
|
isPullRequest: Boolean)
|
||||||
@@ -179,7 +179,7 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def createIssue(owner: String, repository: String, loginUser: String, title: String, content: Option[String],
|
def createIssue(owner: String, repository: String, loginUser: String, title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int]) =
|
assignedUserName: Option[String], milestoneId: Option[Int], isPullRequest: Boolean = false) =
|
||||||
// next id number
|
// next id number
|
||||||
sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int]
|
sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int]
|
||||||
.firstOption.filter { id =>
|
.firstOption.filter { id =>
|
||||||
@@ -194,7 +194,8 @@ trait IssuesService {
|
|||||||
content,
|
content,
|
||||||
false,
|
false,
|
||||||
currentDate,
|
currentDate,
|
||||||
currentDate)
|
currentDate,
|
||||||
|
isPullRequest)
|
||||||
|
|
||||||
// increment issue id
|
// increment issue id
|
||||||
IssueId
|
IssueId
|
||||||
|
|||||||
Reference in New Issue
Block a user