Merge pull request #612 from team-lab/fix/update-pullrequest-on-commit-by-online-editor

fix/update pullrequest when file edited by online editor
This commit is contained in:
Naoki Takezoe
2015-01-31 18:19:46 +09:00
4 changed files with 39 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ package service
import model.Profile._
import profile.simple._
import model.{PullRequest, Issue}
import util.JGitUtil
trait PullRequestService { self: IssuesService =>
import PullRequestService._
@@ -81,6 +82,18 @@ trait PullRequestService { self: IssuesService =>
.map { case (t1, t2) => t1 }
.list
/**
* Fetch pull request contents into refs/pull/${issueId}/head and update pull request table.
*/
def updatePullRequests(owner: String, repository: String, branch: String)(implicit s: Session): Unit =
getPullRequestsByRequest(owner, repository, branch, false).foreach { pullreq =>
if(Repositories.filter(_.byRepository(pullreq.userName, pullreq.repositoryName)).exists.run){
val (commitIdTo, commitIdFrom) = JGitUtil.updatePullRequest(
pullreq.userName, pullreq.repositoryName, pullreq.branch, pullreq.issueId,
pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch)
updateCommitId(pullreq.userName, pullreq.repositoryName, pullreq.issueId, commitIdTo, commitIdFrom)
}
}
}
object PullRequestService {