public String getCurrentLogin() { return this.user.getLogin(); }
public Iterable<GHRepository> getRepositories(final String orgName) { try { if (orgName.equals(this.user.getLogin())) { return this.gh.getMyself().listRepositories(); } else { return this.gh.getOrganization(orgName).listRepositories(); } } catch (final IOException e) { throw new RuntimeException(e); } }
/** * @deprecated * Use {@link #getEmails2()} */ public List<String> getEmails() throws IOException { List<GHEmail> src = getEmails2(); List<String> r = new ArrayList<String>(src.size()); for (GHEmail e : src) { r.add(e.getEmail()); } return r; }
@POST public FormValidation doTestGithubAccess( @QueryParameter("serverAPIUrl") final String serverAPIUrl, @QueryParameter("credentialsId") final String credentialsId) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); try { GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId); if (builder == null) { return FormValidation.error("Unable to look up GitHub credentials using ID: " + credentialsId + "!!"); } GitHub gh = builder.build(); GHMyself me = gh.getMyself(); String name = me.getName(); String email = me.getEmail(); String login = me.getLogin(); String comment = String.format("Connected to %s as %s (%s) login: %s", serverAPIUrl, name, email, login); return FormValidation.ok(comment); } catch (Exception ex) { return FormValidation.error("Unable to connect to GitHub API: " + ex); } }
@Override public List<Organization> getOrganizations(String accessToken) throws IOException, ServiceException { GitHub gitHub = GitHub.connectUsingOAuth(accessToken); List<Organization> organizations = gitHub.getMyself().getAllOrganizations().stream().map(organization -> { Organization result = new Organization(organization.getLogin()); result.setAvatarURL(organization.getAvatarUrl()); return result; }).collect(Collectors.toList()); Organization myself = new Organization(gitHub.getMyself().getLogin()); myself.setAvatarURL(gitHub.getMyself().getAvatarUrl()); organizations.add(myself); return organizations; }
throw new AbortException(rle.getMessage()); if (myself != null && repoOwner.equalsIgnoreCase(myself.getLogin())) { listener.getLogger().format("Looking up %s repository of myself %s%n%n", sourceName, repoOwner); GHRepository repo = myself.getRepository(sourceName); if (repo != null && repo.getOwnerName().equals(repoOwner)) { if (request.process(repo.getName(), sourceFactory, null, witness)) {
/** * Lists up all repositories this user owns (public and private). * * Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned. * Repositories are returned by GitHub API with a 30 items per page. */ @Override public PagedIterable<GHRepository> listRepositories() { return listRepositories(30); }
/** * @deprecated * Use {@link #listRepositories()} */ public PagedIterable<GHRepository> listAllRepositories() { return listRepositories(); }
private void cleanBefore() throws Exception { String login = github.getMyself().getLogin(); List<String> repoNames = Arrays.asList( Paths.get(login, NAME).toString(), Paths.get(ORG, NAME).toString(), Paths.get(login, STORE_NAME).toString()); for (String repoName : repoNames) { TestCommon.checkAndDeleteBefore(repoName, github); } }
throw new FillErrorResponse(e.getMessage(), false); if (myself != null && repoOwner.equalsIgnoreCase(myself.getLogin())) { Set<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); for (GHRepository repo : myself.listRepositories(100, GHMyself.RepositoryListFilter.OWNER)) { result.add(repo.getName());
/** * @deprecated * Use {@link #listRepositories()} */ public PagedIterable<GHRepository> listAllRepositories() { return listRepositories(); }
/** * @deprecated * Use {@link #getEmails2()} */ public List<String> getEmails() throws IOException { List<GHEmail> src = getEmails2(); List<String> r = new ArrayList<String>(src.size()); for (GHEmail e : src) { r.add(e.getEmail()); } return r; }
public static void addVersionStoreRepo(GitHub github, List<GHRepository> createdRepos, String storeName) throws IOException { String login = github.getMyself().getLogin(); GHRepository storeRepo = github.getRepository(Paths.get(login, storeName).toString()); createdRepos.add(storeRepo); } }
throw new AbortException(rle.getMessage()); if (myself != null && repoOwner.equalsIgnoreCase(myself.getLogin())) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "Looking up repositories of myself %s", repoOwner ))); for (GHRepository repo : myself.listRepositories(100)) { Connector.checkApiRateLimit(listener, github); if (!repo.getOwnerName().equals(repoOwner)) {
/** * Lists up all repositories this user owns (public and private). * * Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned. * Repositories are returned by GitHub API with a 30 items per page. */ @Override public PagedIterable<GHRepository> listRepositories() { return listRepositories(30); }
/** * @deprecated * Use {@link #getEmails2()} */ public List<String> getEmails() throws IOException { List<GHEmail> src = getEmails2(); List<String> r = new ArrayList<String>(src.size()); for (GHEmail e : src) { r.add(e.getEmail()); } return r; }
/** * Returns the read-only list of all the public verified keys of the current user. * * Differently from the getPublicKeys() method, the retrieval of the user's * verified public keys does not require any READ/WRITE OAuth Scope to the * user's profile. * * @return * Always non-null. */ public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException { return Collections.unmodifiableList(Arrays.asList(root.retrieve().to( "/users/" + getLogin() + "/keys", GHVerifiedKey[].class))); }
/** * @deprecated * Use {@link #listRepositories()} */ public PagedIterable<GHRepository> listAllRepositories() { return listRepositories(); }