(refs #2)Pull request works!

This commit is contained in:
takezoe
2013-08-05 00:49:09 +09:00
parent aa5fdfa395
commit 1d03a82be4

View File

@@ -102,26 +102,34 @@ trait PullRequestsControllerBase extends ControllerBase {
updateClosed(repository.owner, repository.name, issueId, true) updateClosed(repository.owner, repository.name, issueId, true)
recordMergeActivity(repository.owner, repository.name, loginAccount.userName, issueId, form.message) recordMergeActivity(repository.owner, repository.name, loginAccount.userName, issueId, form.message)
git.checkout.setName(pullreq.branch).call // fetch pull request to working repository
git.fetch git.fetch
.setRemote(getRepositoryDir(repository.owner, repository.name).toURI.toString) .setRemote(getRepositoryDir(repository.owner, repository.name).toURI.toString)
.setRefSpecs(new RefSpec(s"refs/pull/${issueId}/head:refs/heads/${pullreq.branch}")).call .setRefSpecs(new RefSpec(s"refs/pull/${issueId}/head:refs/heads/gitbucket-merge-${issueId}")).call
// merge pull request
git.checkout.setName(pullreq.branch).call
val result = git.merge val result = git.merge
.include(git.getRepository.resolve("FETCH_HEAD")) .include(git.getRepository.resolve(s"gitbucket-merge-${issueId}"))
.setFastForward(FastForwardMode.NO_FF) .setFastForward(FastForwardMode.NO_FF)
.setCommit(true).call .setCommit(false)
.call
if(result.getConflicts != null){ if(result.getConflicts != null){
throw new RuntimeException("This pull request can't merge automatically.") throw new RuntimeException("This pull request can't merge automatically.")
} }
// TODO merge commit // merge commit
// git.commit git.getRepository.writeMergeCommitMsg(
// .setCommitter(new PersonIdent(loginAccount.userName, loginAccount.mailAddress)) s"Merge pull request #${issueId} from ${pullreq.requestUserName}/${pullreq.requestRepositoryName}\n"
// .setMessage(s"Merge pull request #${issueId} from ${pullreq.requestUserName}/${pullreq.requestRepositoryName}\n" + form.message)
// + form.message).call
git.commit
.setCommitter(new PersonIdent(loginAccount.userName, loginAccount.mailAddress))
.call
// push
git.push.call git.push.call
val (commits, _) = getRequestCompareInfo(repository.owner, repository.name, pullreq.commitIdFrom, val (commits, _) = getRequestCompareInfo(repository.owner, repository.name, pullreq.commitIdFrom,
@@ -137,7 +145,7 @@ trait PullRequestsControllerBase extends ControllerBase {
} finally { } finally {
git.getRepository.close git.getRepository.close
FileUtils.deleteDirectory(tmpdir) // FileUtils.deleteDirectory(tmpdir)
} }
} getOrElse NotFound } getOrElse NotFound
} }