Ignore TransportException if the source branch had been removed.

This commit is contained in:
takezoe
2013-11-25 18:16:38 +09:00
parent 19dee09c86
commit 5790d246c8

View File

@@ -18,6 +18,7 @@ import util.JGitUtil.CommitInfo
import org.slf4j.LoggerFactory
import org.eclipse.jgit.merge.MergeStrategy
import org.eclipse.jgit.errors.NoMergeBaseException
import org.eclipse.jgit.api.errors.TransportException
class PullRequestsController extends PullRequestsControllerBase
with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with ActivityService
@@ -450,12 +451,16 @@ trait PullRequestsControllerBase extends ControllerBase {
* 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
try {
git.fetch
.setRemote(getRepositoryDir(requestUserName, requestRepositoryName).toURI.toString)
.setRefSpecs(new RefSpec(s"refs/heads/${requestBranch}:refs/pull/${issueId}/head").setForceUpdate(true))
.call
} catch {
case ex: TransportException => // ignore
}
git.getRepository.resolve(s"refs/pull/${issueId}/head").getName
}
}