當前位置: 首頁>>代碼示例>>Java>>正文


Java GitHub.getMyself方法代碼示例

本文整理匯總了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);
}
 
開發者ID:payne,項目名稱:github_cleaner,代碼行數:17,代碼來源:MainCleanup.java

示例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!");
    }
}
 
開發者ID:fabric8-updatebot,項目名稱:updatebot,代碼行數:32,代碼來源:GitPluginCLI.java

示例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);
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_github,代碼行數:10,代碼來源:GitHubOAuthServiceProvider.java

示例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);
    }
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:16,代碼來源:GhprcGitHubAuth.java

示例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);
    }
}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:9,代碼來源:GithubCurrentUserService.java

示例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();
	}
}
 
開發者ID:payne,項目名稱:github_cleaner,代碼行數:32,代碼來源:Main.java

示例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());
}
 
開發者ID:gocd-contrib,項目名稱:github-oauth-authorization-plugin,代碼行數:6,代碼來源:LoggedInUserInfo.java


注:本文中的org.kohsuke.github.GitHub.getMyself方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。