本文整理汇总了Java中org.kohsuke.github.GHUser类的典型用法代码示例。如果您正苦于以下问题:Java GHUser类的具体用法?Java GHUser怎么用?Java GHUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GHUser类属于org.kohsuke.github包,在下文中一共展示了GHUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.kohsuke.github.GHUser; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
GHUser author = mock(GHUser.class);
when(author.getName()).thenReturn("Hazelcast");
repo = mock(GHRepository.class, RETURNS_DEEP_STUBS);
when(repo.getIssue(anyInt()).getUser()).thenReturn(author);
when(repo.getName()).thenReturn("hazelcast");
PropertyReader props = new PropertyReader("host", "username", "password");
props.setMinCodeCoverage(87.5, false);
props.setMinCodeCoverage(60.0, true);
JsonDownloader jsonDownloader = mock(JsonDownloader.class);
reader = new CodeCoverageReader(props, repo, jsonDownloader);
}
示例2: searchUser
import org.kohsuke.github.GHUser; //导入依赖的package包/类
@Override
public List<User> searchUser(GithubPluginSettings pluginSettings, String searchTerm) {
List<User> users = new ArrayList<User>();
try {
GitHub github = getGitHub(pluginSettings);
PagedSearchIterable<GHUser> githubSearchResults = github.searchUsers().q(searchTerm).list();
int count = 0;
for (GHUser githubSearchResult : githubSearchResults) {
users.add(new User(githubSearchResult.getLogin(), githubSearchResult.getName(), githubSearchResult.getEmail()));
count++;
if (count == 10) {
break;
}
}
} catch (Exception e) {
LOGGER.warn("Error occurred while trying to perform user search", e);
}
return users;
}
示例3: isAMemberOfOrganization
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private boolean isAMemberOfOrganization(GithubPluginSettings pluginSettings, User user) {
try {
GitHub github = getGitHub(pluginSettings);
GHUser ghUser = github.getUser(user.getUsername());
if(ghUser == null) return false;
for(String orgName: pluginSettings.getGithubOrganizations()) {
GHOrganization organization = github.getOrganization(orgName);
if(organization != null && ghUser.isMemberOf(organization)){
return true;
}
}
} catch (Exception e) {
LOGGER.warn("Error occurred while trying to check if user is member of organization", e);
}
return false;
}
示例4: isOwnCode
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private boolean isOwnCode(GHPullRequest pr, GHUser committer) {
try {
String commentorName = committer.getName();
for (GHPullRequestCommitDetail detail : pr.listCommits()) {
Commit commit = detail.getCommit();
String committerName = commit.getCommitter().getName();
if (committerName.equalsIgnoreCase(commentorName)) {
return true;
}
}
} catch (IOException e) {
logger.println("Unable to get committer name");
e.printStackTrace(logger);
}
return false;
}
示例5: updatePR
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private void updatePR(GHPullRequest pr, GHUser author) {
if (pr != null && isUpdated(pr)) {
logger.log(Level.INFO, "Pull request #{0} was updated on {1} at {2} by {3}", new Object[] { id, reponame, updated, author });
// the title could have been updated since the original PR was opened
title = pr.getTitle();
boolean newCommit = checkCommit(pr.getHead().getSha());
if (!newCommit) {
logger.log(Level.INFO, "Pull request #{0} was updated on repo {1} but there aren''t any new comments nor commits; "
+ "that may mean that commit status was updated.",
new Object[] { id, reponame }
);
}
}
}
示例6: should_create_a_new_project
import org.kohsuke.github.GHUser; //导入依赖的package包/类
@Test
@LocalData
public void should_create_a_new_project() throws Exception {
GHRepository ghRepository = mock(GHRepository.class);
when(ghRepository.getHtmlUrl()).thenReturn(new URL("http://github.com/meow"));
GHUser ghUser = mock(GHUser.class);
when(ghUser.getLogin()).thenReturn("test_user");
when(ghRepository.getOwner()).thenReturn(ghUser);
when(ghRepository.getName()).thenReturn("test_job");
int totalBefore = (int) repo.getDatastore().createQuery(DynamicProject.class).countAll();
DynamicProject project = repo.createNewProject(ghRepository, "test", "username");
assertNotNull(project);
DynamicProject retrieved = repo.getProjectById(project.getId());
assertNotNull(retrieved);
int totalAfter = (int) repo.getDatastore().createQuery(DynamicProject.class).countAll();
assertEquals(totalAfter, totalBefore + 1);
}
示例7: backupTeams
import org.kohsuke.github.GHUser; //导入依赖的package包/类
/**
* Writes out individual team information, one team per file, to the given
* directory.
*
* @param git - local git repository
* @param teams - list of teams to back up
* @param baseDir - base directory to write teams
*/
private void backupTeams(Git git, Set<GHTeam> teams, String baseDir) {
for (GHTeam team : teams) {
if (checkPoint(git, ResumePoint.teamMembers(team.getId()))) {
String teamPath = getFilePath(baseDir, team.getId());
BufferedWriter writer = getWriter(teamPath);
// Write all info for the current team
writeLine(writer, "name: " + team.getName());
writeLine(writer, "permission: " + team.getPermission());
writeLine(writer, "members:");
try {
for (GHUser member : team.getMembers()) {
writeLine(writer, "\t" + member.getLogin() + ", " + member.getId());
}
}
catch (IOException e) {
err("No team member information for team: " + team.getName());
}
cleanUp(teamPath, git, writer);
}
}
cleanEmptyDir(baseDir);
}
示例8: updateBotCommentCommand
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private String updateBotCommentCommand(CommandContext context, GHIssueComment comment) throws IOException {
GHUser user = comment.getUser();
if (user != null) {
if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) {
String body = comment.getBody();
if (body != null) {
body = body.trim();
if (body.startsWith(PullRequests.COMMAND_COMMENT_PREFIX)) {
return body;
}
}
}
}
return null;
}
示例9: updateBotIssuePendingChangesComment
import org.kohsuke.github.GHUser; //导入依赖的package包/类
public static String updateBotIssuePendingChangesComment(CommandContext context, GHIssueComment comment) throws IOException {
GHUser user = comment.getUser();
if (user != null) {
if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) {
String body = comment.getBody();
if (body != null) {
body = body.trim();
if (body.startsWith(PENDING_CHANGE_COMMENT_PREFIX)) {
return body;
}
}
}
}
return null;
}
示例10: User
import org.kohsuke.github.GHUser; //导入依赖的package包/类
public User(GHUser ghUser) {
this.profileId = String.valueOf(ghUser.getId());
this.screenName = ghUser.getLogin();
this.url = ghUser.getHtmlUrl().toString();
this.profileImageUrl = ghUser.getAvatarUrl();
try {
this.name = ghUser.getName();
this.location = ghUser.getLocation();
this.followerCount = ghUser.getFollowersCount();
this.followsCount = ghUser.getFollowingCount();
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: getAuthor
import org.kohsuke.github.GHUser; //导入依赖的package包/类
public static String getAuthor(GHRepository repo, int gitPullRequest) {
return (String) execute(TimeTrackerLabel.GET_AUTHOR, () -> {
GHUser user = repo.getIssue(gitPullRequest).getUser();
String author = user.getName();
if (author != null) {
return author;
}
return user.getLogin();
});
}
示例12: isUserMemberOfOrganization
import org.kohsuke.github.GHUser; //导入依赖的package包/类
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;
}
示例13: isInWhitelistedOrg
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private boolean isInWhitelistedOrg(@Nonnull GHUser user) {
boolean ret = false;
for (String organisation : orgsSet) {
try {
ret = isUserMemberOfOrganization(organisation, user);
if (ret) {
break;
}
} catch (IOException e) {
LOGGER.error("Can't connect retrieve organization data from GitHub", e);
}
}
return ret;
}
示例14: isMyselfUser
import org.kohsuke.github.GHUser; //导入依赖的package包/类
private static boolean isMyselfUser(GHUser user) {
boolean ret = false;
if (isNull(user)) {
return false;
}
try {
GitHub github = githubFor(URI.create(user.getHtmlUrl().toString()));
ret = StringUtils.equals(user.getLogin(), github.getMyself().getLogin());
} catch (IOException e) {
LOGGER.error("Can't connect retrieve user data from GitHub", e);
}
return ret;
}
示例15: GitHubPRCause
import org.kohsuke.github.GHUser; //导入依赖的package包/类
public GitHubPRCause(GitHubPRPullRequest pr,
GHUser triggerSender,
boolean skip,
String reason) throws IOException {
this(pr.getHeadSha(), pr.getNumber(),
pr.isMergeable(), pr.getBaseRef(), pr.getHeadRef(),
pr.getUserEmail(), pr.getTitle(), pr.getHtmlUrl(), pr.getSourceRepoOwner(),
pr.getLabels(),
triggerSender, skip, reason, "", "", pr.getState());
this.body = pr.getBody();
}