本文整理匯總了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());
}
}
});
}