本文整理匯總了Java中org.kohsuke.github.GitHub.getMyself方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.getMyself方法的具體用法?Java GitHub.getMyself怎麽用?Java GitHub.getMyself使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kohsuke.github.GitHub
的用法示例。
在下文中一共展示了GitHub.getMyself方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteRepos
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private void deleteRepos(List<String> lstReposToDelete) throws IOException {
GitHub github = GitHub.connect();
GHMyself me = github.getMyself();
PagedIterable<GHRepository> lstRepos = me.listRepositories();
int cntDeleted = 0;
for (GHRepository repo : lstRepos) {
String name = repo.getName();
if (lstReposToDelete.contains(name)) {
repo.delete();
cntDeleted++;
System.out.format("Deleted: %s\n", name);
}
}
System.out.format("That's %d repositories deleted!\n",
cntDeleted);
}
示例2: configUserNameAndEmail
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public void configUserNameAndEmail(File dir) {
String email = null;
String personName = null;
try {
GitHub github = configuration.getGithub();
if (github != null) {
GHMyself myself = github.getMyself();
if (myself != null) {
email = myself.getEmail();
personName = myself.getName();
if (Strings.empty(personName)) {
configuration.warn(LOG, "No name available for GitHub login!");
personName = myself.getLogin();
}
}
}
} catch (IOException e) {
configuration.warn(LOG, "Failed to load github username and email: " + e, e);
}
if (Strings.notEmpty(email)) {
ProcessHelper.runCommandAndLogOutput(configuration, LOG, dir, "git", "config", "user.email", email);
} else {
configuration.error(LOG, "No email available for GitHub login!");
}
if (Strings.notEmpty(personName)) {
ProcessHelper.runCommandAndLogOutput(configuration, LOG, dir, "git", "config", "user.name", personName);
} else {
configuration.error(LOG, "No name available for GitHub login!");
}
}
示例3: getUserInfo
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public OAuthUserInfo getUserInfo(OAuthToken token) throws IOException {
String oauthToken = token.getToken();
GitHub hub = GitHub.connectUsingOAuth(oauthToken);
GHMyself myself = hub.getMyself();
String login = myself.getLogin();
return new OAuthUserInfo(
ExternalId.SCHEME_GERRIT + login, login, myself.getEmail(), myself.getName(), null);
}
示例4: doTestGithubAccess
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public FormValidation doTestGithubAccess(
@QueryParameter("serverAPIUrl") final String serverAPIUrl,
@QueryParameter("credentialsId") final String credentialsId) {
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();
return FormValidation.ok("Connected to " + serverAPIUrl + " as " + me.getName());
} catch (Exception ex) {
return FormValidation.error("Unable to connect to GitHub API: " + ex);
}
}
示例5: GithubCurrentUserService
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public GithubCurrentUserService(final GitHub gh) {
this.gh = gh;
try {
this.user = gh.getMyself();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
示例6: run
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private void run() throws IOException {
GitHub github = GitHub.connect();
Map<String, GHOrganization> orgs = github.getMyOrganizations();
System.out.println(orgs);
GHMyself me = github.getMyself();
PagedIterable<GHRepository> lstRepos = me.listRepositories();
// TODO:mgp: Figure out what I am missing here.
int counterSinceThereSeemsToBeNoSizeMethodOnPagedIterable = 0;
GHRepository repoToDelete = null;
PrintWriter outCloneList = new PrintWriter("clone_these.sh");
PrintWriter outRepoList = new PrintWriter("repo_list.txt");
for (GHRepository repo : lstRepos) {
String name = repo.getName();
Date pushedAt = repo.getPushedAt();
String readOnlyUrl = repo.getGitTransportUrl();
outRepoList.format("%s\n", name);
outCloneList.println(readOnlyUrl);
counterSinceThereSeemsToBeNoSizeMethodOnPagedIterable++;
if (name.equals("c-style")) {
repoToDelete = repo;
System.out.println("Well?");
}
}
outCloneList.close();
outRepoList.close();
System.out.format("That's %d repositories!\n",
counterSinceThereSeemsToBeNoSizeMethodOnPagedIterable);
if (null != repoToDelete) {
repoToDelete.delete();
}
}
示例7: LoggedInUserInfo
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public LoggedInUserInfo(GitHub gitHub) throws IOException {
this.gitHub = gitHub;
gitHubUser = gitHub.getMyself();
user = new User(gitHubUser.getLogin(), gitHubUser.getName(), gitHubUser.getEmail());
}