Fetch pull request from source repository after updating repository.

This commit is contained in:
odz
2013-11-20 23:59:26 +09:00
parent f38924c7fe
commit 223ba791fe
4 changed files with 42 additions and 18 deletions

View File

@@ -70,11 +70,8 @@ trait PullRequestsControllerBase extends ControllerBase {
val name = repository.name
getPullRequest(owner, name, issueId) map { case(issue, pullreq) =>
using(Git.open(getRepositoryDir(owner, name))){ git =>
// prepare head branch
val commitIdTo = fetchPullRequest(git, issueId, pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch)
updateCommitIdTo(owner, name, issueId, commitIdTo)
val (commits, diffs) = getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, commitIdTo)
val (commits, diffs) =
getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, pullreq.commitIdTo)
pulls.html.pullreq(
issue, pullreq,
@@ -446,16 +443,4 @@ trait PullRequestsControllerBase extends ControllerBase {
hasWritePermission(owner, repoName, context.loginAccount))
}
/**
* Fetch pull request contents into refs/pull/${issueId}/head and return the head commit id of the pull request.
*/
private def fetchPullRequest(git: Git, issueId: Int, requestUserName: String, requestRepositoryName: String, requestBranch: String): String = {
git.fetch
.setRemote(getRepositoryDir(requestUserName, requestRepositoryName).toURI.toString)
.setRefSpecs(new RefSpec(s"refs/heads/${requestBranch}:refs/pull/${issueId}/head").setForceUpdate(true))
.call
git.getRepository.resolve(s"refs/pull/${issueId}/head").getName
}
}