use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method findRepositoryNamesWithAdminPermission.
@Override
@SneakyThrows
public List<String> findRepositoryNamesWithAdminPermission(String accessToken) {
GitHubClient client = createClient(accessToken);
WithPermissionsRepositoryService service = new WithPermissionsRepositoryService(client);
List<WithPermissionsRepository> repositories = service.getPermissionRepositories();
List<String> repoSlugs = new ArrayList<>();
for (WithPermissionsRepository r : repositories) {
if (!r.getPermissions().isAdmin()) {
continue;
}
org.eclipse.egit.github.core.User owner = r.getOwner();
repoSlugs.add(owner.getLogin() + "/" + r.getName());
}
return repoSlugs;
}
use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method save.
@SneakyThrows
public void save(PullRequestStatus commitStatus) {
String repoId = commitStatus.getRepoId();
String accessToken = commitStatus.getAccessToken();
if (accessToken == null) {
return;
}
PullRequestId pullRequestId = PullRequestId.of(RepositoryId.createFromId(repoId), commitStatus.getPullRequestId());
boolean hasSignedCla = commitStatus.isSuccess();
GitHubClient client = createClient(accessToken);
String claUserLogin = getGitHubClaUserLogin();
List<Comment> comments = getComments(pullRequestId, getIssueService());
boolean obviousFix = isObviousFix(pullRequestId, comments, claUserLogin, commitStatus.getPullRequestBody());
ContextCommitStatus status = createCommitStatusIfNecessary(pullRequestId, commitStatus, hasSignedCla, obviousFix, client);
createOrUpdatePullRequestComment(pullRequestId, commitStatus, hasSignedCla, obviousFix, status, comments, claUserLogin);
}
use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method getOrganizations.
@SneakyThrows
public List<String> getOrganizations(String username) {
OrganizationService orgs = new OrganizationService(createClient(oauthConfig.getPivotalClaAccessToken()));
List<org.eclipse.egit.github.core.User> organizations = orgs.getOrganizations(username);
return organizations.stream().map(o -> o.getLogin()).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
}
use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method getCurrentGitHubUser.
@SneakyThrows
private org.eclipse.egit.github.core.User getCurrentGitHubUser(String accessToken) {
GitHubClient client = createClient(accessToken);
org.eclipse.egit.github.core.service.UserService githubUsers = new org.eclipse.egit.github.core.service.UserService(client);
return githubUsers.getUser();
}
use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method findPullRequest.
@Override
@SneakyThrows
public Optional<PullRequest> findPullRequest(String repoId, int pullRequestId, String accessToken) {
GitHubClient client = createClient(accessToken);
PullRequestService service = new PullRequestService(client);
try {
return Optional.ofNullable(service.getPullRequest(RepositoryId.createFromId(repoId), pullRequestId));
} catch (RequestException e) {
if (e.getStatus() == HttpStatus.NOT_FOUND.value()) {
return Optional.empty();
}
throw e;
}
}
Aggregations