本文整理匯總了Java中org.kohsuke.github.GitHub.getUser方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.getUser方法的具體用法?Java GitHub.getUser怎麽用?Java GitHub.getUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kohsuke.github.GitHub
的用法示例。
在下文中一共展示了GitHub.getUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isAMemberOfOrganization
import org.kohsuke.github.GitHub; //導入方法依賴的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;
}
示例2: getUser
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
* Helper method to get a GitHub user. Consumes any exceptions. The user is
* determined by the {@link #user} parameter. This operation requires one
* GitHub API access.
*
* @param remote - Remote to check for the current user.
* @return A GHUser if the specified user if found, or null
*/
private GHUser getUser(GitHub remote) {
try {
// Make sure we have the GitHub access available
if (canGetBase()) {
return remote.getUser(user);
}
}
catch (IOException e) {
err("Failed to find user: " + user);
e.printStackTrace();
}
return null;
}