本文整理汇总了Java中org.eclipse.che.plugin.pullrequest.client.vcs.hosting.NoCommitsInPullRequestException类的典型用法代码示例。如果您正苦于以下问题:Java NoCommitsInPullRequestException类的具体用法?Java NoCommitsInPullRequestException怎么用?Java NoCommitsInPullRequestException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoCommitsInPullRequestException类属于org.eclipse.che.plugin.pullrequest.client.vcs.hosting包,在下文中一共展示了NoCommitsInPullRequestException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPullRequest
import org.eclipse.che.plugin.pullrequest.client.vcs.hosting.NoCommitsInPullRequestException; //导入依赖的package包/类
@Override
public Promise<PullRequest> createPullRequest(
final String owner,
final String repository,
final String username,
final String headBranchName,
final String baseBranchName,
final String title,
final String body) {
final BitbucketPullRequestLocation destination =
dtoFactory
.createDto(BitbucketPullRequestLocation.class)
.withBranch(
dtoFactory.createDto(BitbucketPullRequestBranch.class).withName(baseBranchName))
.withRepository(
dtoFactory
.createDto(BitbucketPullRequestRepository.class)
.withFullName(owner + '/' + repository));
final BitbucketPullRequestLocation sources =
dtoFactory
.createDto(BitbucketPullRequestLocation.class)
.withBranch(
dtoFactory.createDto(BitbucketPullRequestBranch.class).withName(headBranchName))
.withRepository(
dtoFactory
.createDto(BitbucketPullRequestRepository.class)
.withFullName(username + '/' + repository));
final BitbucketPullRequest pullRequest =
dtoFactory
.createDto(BitbucketPullRequest.class)
.withTitle(title)
.withDescription(body)
.withDestination(destination)
.withSource(sources);
return bitbucketClientService
.openPullRequest(owner, repository, pullRequest)
.then(
new Function<BitbucketPullRequest, PullRequest>() {
@Override
public PullRequest apply(BitbucketPullRequest arg) throws FunctionException {
return valueOf(arg);
}
})
.catchErrorPromise(
error -> {
final String message = error.getMessage();
if (isNullOrEmpty(message)) {
return reject(error);
}
if (getErrorCode(error.getCause()) == BAD_REQUEST
&& containsIgnoreCase(message, NO_CHANGES_TO_BE_PULLED_ERROR_MESSAGE)) {
return reject(
JsPromiseError.create(
new NoCommitsInPullRequestException(headBranchName, baseBranchName)));
} else if (containsIgnoreCase(message, PULL_REQUEST_ALREADY_EXISTS_ERROR_MESSAGE)) {
return reject(
JsPromiseError.create(new PullRequestAlreadyExistsException(headBranchName)));
}
return reject(error);
});
}
示例2: createPullRequest
import org.eclipse.che.plugin.pullrequest.client.vcs.hosting.NoCommitsInPullRequestException; //导入依赖的package包/类
@Override
public Promise<PullRequest> createPullRequest(
final String owner,
final String repository,
final String username,
final String headBranchName,
final String baseBranchName,
final String title,
final String body) {
final String brName = username + ":" + headBranchName;
final GitHubPullRequestCreationInput input =
dtoFactory
.createDto(GitHubPullRequestCreationInput.class)
.withTitle(title)
.withHead(brName)
.withBase(baseBranchName)
.withBody(body);
return oAuthServiceClient
.getToken(SERVICE_NAME.toLowerCase())
.thenPromise(
token ->
gitHubClientService.createPullRequest(token.getToken(), owner, repository, input))
.then(
new Function<GitHubPullRequest, PullRequest>() {
@Override
public PullRequest apply(GitHubPullRequest arg) throws FunctionException {
return valueOf(arg);
}
})
.catchErrorPromise(
new Function<PromiseError, Promise<PullRequest>>() {
@Override
public Promise<PullRequest> apply(PromiseError err) throws FunctionException {
final String msg = err.getMessage();
if (containsIgnoreCase(msg, NO_COMMITS_IN_PULL_REQUEST_ERROR_MESSAGE)) {
return Promises.reject(
JsPromiseError.create(
new NoCommitsInPullRequestException(brName, baseBranchName)));
} else if (containsIgnoreCase(msg, PULL_REQUEST_ALREADY_EXISTS_ERROR_MESSAGE)) {
return Promises.reject(
JsPromiseError.create(new PullRequestAlreadyExistsException(brName)));
} else if (containsIgnoreCase(msg, NO_HISTORYIN_COMMON_ERROR_MESSAGE)) {
return Promises.reject(
JsPromiseError.create(
new NoHistoryInCommonException(
"The "
+ brName
+ " branch has no history in common with "
+ owner
+ ':'
+ baseBranchName)));
}
return Promises.reject(err);
}
});
}
示例3: execute
import org.eclipse.che.plugin.pullrequest.client.vcs.hosting.NoCommitsInPullRequestException; //导入依赖的package包/类
@Override
public void execute(final WorkflowExecutor executor, final Context context) {
final Configuration configuration = context.getConfiguration();
context
.getVcsHostingService()
.createPullRequest(
context.getOriginRepositoryOwner(),
context.getOriginRepositoryName(),
context.getHostUserLogin(),
context.getWorkBranchName(),
context.getContributeToBranchName(),
configuration.getContributionTitle(),
configuration.getContributionComment())
.then(
new Operation<PullRequest>() {
@Override
public void apply(PullRequest pullRequest) throws OperationException {
context.setPullRequestIssueNumber(pullRequest.getNumber());
context.setPullRequest(pullRequest);
executor.done(IssuePullRequestStep.this, context);
}
})
.catchError(
new Operation<PromiseError>() {
@Override
public void apply(final PromiseError exception) throws OperationException {
try {
throw exception.getCause();
} catch (PullRequestAlreadyExistsException | NoHistoryInCommonException ex) {
executor.fail(IssuePullRequestStep.this, context, ex.getLocalizedMessage());
} catch (NoCommitsInPullRequestException noCommitsEx) {
executor.fail(
IssuePullRequestStep.this,
context,
messages.stepIssuePullRequestErrorCreatePullRequestWithoutCommits());
} catch (Throwable thr) {
executor.fail(
IssuePullRequestStep.this,
context,
messages.stepIssuePullRequestErrorCreatePullRequest());
}
}
});
}