/** * Quick way to just get the actor of the login. */ public String getActorLogin() throws IOException { return actor.getLogin(); }
/** * Email address is collected from GitHub as extra information, so lets cache it. * * @return The PR authors email address */ public String getAuthorEmail() { if (StringUtils.isEmpty(authorEmail)) { try { GHUser user = getPullRequestAuthor(); authorEmail = user.getEmail(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Unable to fetch author info for " + id); } } authorEmail = StringUtils.isEmpty(authorEmail) ? "" : authorEmail; return authorEmail; }
@Override public boolean equals(Object obj) { // We ignore contributions in the calculation return super.equals(obj); } }
public boolean isUserMemberOfOrganization(String organisation, GHUser member) throws IOException { boolean orgHasMember; //TODO check for null member GitHub github = githubFor(URI.create(member.getHtmlUrl().toString())); orgHasMember = github.getOrganization(organisation).hasMember(member); LOGGER.debug("org.hasMember(member)? user:'{}' org: '{}' == '{}'", member.getLogin(), organisation, orgHasMember ? "yes" : "no"); return orgHasMember; }
listener.getLogger().println("Comment from bot user " + triggerSender.getLogin() + " ignored."); return; canMerge = false; final String msg = "Only admins can merge this pull request, " + (triggerSender != null ? triggerSender.getLogin() + " is not an admin" : " and build was triggered via automation") + "."; listener.getLogger().println(msg); String.format( "Code not merged because @%s (%s) is not in the Admin list.", triggerSender.getLogin(), triggerSender.getName() String.format( "Code not merged because @%s (%s) has committed code in the request.", triggerSender.getLogin(), triggerSender.getName()
public Optional<CommitDetails> getCommitDetails(String githubRepo, String sha) { try { logger.info("Getting commit details for sha {} on url {}", sha, githubRepo); GHCommit commit = gitHub.getRepository(githubRepo).getCommit(sha); GHUser author = commit.getAuthor(); String committerName = (author == null) ? null : author.getName(); if (committerName == null || committerName.isEmpty()) { committerName = author.getLogin(); } CommitDetails commitDetails = new CommitDetails(sha, commit.getHtmlUrl().toString(), commit.getCommitShortInfo().getMessage(), commit.getCommitDate(), commit.getLastStatus(), author.getAvatarUrl(), committerName); return Optional.of(commitDetails); } catch (IOException e) { logger.warn("Could not get commit details from Github!", e); return Optional.empty(); } }
Connector.checkApiRateLimit(listener, hub); GHUser u = hub.getUser(getRepoOwner()); String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm(); result.add(new ObjectMetadataAction( Util.fixEmpty(u.getName()), null, objectUrl) ); result.add(new GitHubOrgMetadataAction(u)); result.add(new GitHubLink("icon-github-logo", u.getHtmlUrl())); if (objectUrl == null) { listener.getLogger().println("Organization URL: unspecified"); } else { listener.getLogger().printf("Organization URL: %s%n", HyperlinkNote.encodeTo(objectUrl, StringUtils.defaultIfBlank(u.getName(), objectUrl)));
public PagedIterator<GHRepository> _iterator(int pageSize) { return new PagedIterator<GHRepository>(root.retrieve().asIterator(getApiTailUrl(suffix), GHRepository[].class, pageSize)) { protected void wrapUp(GHRepository[] page) { for (GHRepository c : page) c.wrap(root); } }; } };
public GitHubOrgMetadataAction(@NonNull GHUser org) throws IOException { this(org.getAvatarUrl()); }
private boolean isOwnCode(GHPullRequest pr, GHUser commenter) { try { String commenterName = commenter.getName(); String commenterEmail = commenter.getEmail(); String commenterLogin = commenter.getLogin(); if (prUser.getLogin().equals(commenterLogin)) { final String msg = commenterName + " (" + commenterLogin + ") has submitted " + "the PR[" + pr.getNumber() + pr.getNumber() + "] that is to be merged";
String body = comment.getBody(); String senderName = sender.getName(); LOGGER.log(Level.FINEST, "[{0}] Added comment: {1}", new Object[] {senderName != null ? senderName : sender.getLogin(), body}); if (!helper.isWhitelisted(author)) { LOGGER.log(Level.FINEST, "Author {0} not whitelisted, adding to whitelist.", author); helper.addWhitelist(author.getLogin());
@Override public PullRequestStatus apply(GHPullRequest input) { int prID = GHUtils.prIdFrom(input.getDiffUrl().toString()); try { GHUser user = input.getUser(); return new PullRequestStatus(prID, input.getHead().getSha(), mergedSHA, input.getHead().getLabel(), input.getBase().getLabel(), input.getHtmlUrl().toString(), user.getName(), user.getEmail(), input.getBody(), input.getTitle()); } catch (IOException e) { throw new RuntimeException(e); } } };
public PagedIterator<GHUser> _iterator(int pageSize) { return new PagedIterator<GHUser>(root.retrieve().asIterator(getApiTailUrl(suffix), GHUser[].class, pageSize)) { protected void wrapUp(GHUser[] page) { GHUser.wrap(page,root); } }; } };
/** * Quick way to just get the actor of the login. */ public String getActorLogin() throws IOException { return actor.getLogin(); }
triggerAuthor = getString(cause.getTriggerSender().getName(), ""); } catch (Exception e) { triggerAuthorEmail = getString(cause.getTriggerSender().getEmail(), ""); } catch (Exception e) { triggerAuthorLogin = getString(cause.getTriggerSender().getLogin(), ""); } catch (Exception e) { values.add(new StringParameterValue("ghprbPullAuthorLogin", String.valueOf(cause.getPullRequestAuthor().getLogin()))); values.add(new StringParameterValue("ghprbPullAuthorLoginMention", "@" + cause.getPullRequestAuthor().getLogin()));