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


Java GitHub.connect方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GitHub.connect方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.connect方法的具體用法?Java GitHub.connect怎麽用?Java GitHub.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GitHub的用法示例。


在下文中一共展示了GitHub.connect方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readGHRepo

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static Optional<GHRepository> readGHRepo() {
	try {
		GitHub github = GitHub.connect();
		String desiredRepo = System.getProperty("GITHUB_REPOSITORY");
		System.out.println("Desired Repo:" + desiredRepo);
		GHRepository repo = github.getRepository(desiredRepo);
		return Optional.of(repo);
	} catch (Exception e) {
		for (Object o : System.getProperties().keySet()) {
			System.out.println(o + ":" + System.getProperty(o + ""));
		}

		for (String env : System.getenv().keySet()) {
			System.out.println(env + ":" + System.getenv(env));
		}
		e.printStackTrace();
		return Optional.empty();
	}
}
 
開發者ID:eraether,項目名稱:WatchWordBot,代碼行數:20,代碼來源:Runner.java

示例2: createGitHubClient

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
GitHub createGitHubClient(String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception {
    GitHub github = null;
    if (usernameAndPasswordIsAvailable(usernameToUse, passwordToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectToEnterprise(endPointToUse, usernameToUse, passwordToUse);
        } else {
            github = GitHub.connectUsingPassword(usernameToUse, passwordToUse);
        }
    }
    if (oAuthTokenIsAvailable(oauthAccessTokenToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectUsingOAuth(endPointToUse, oauthAccessTokenToUse);
        } else {
            github = GitHub.connectUsingOAuth(oauthAccessTokenToUse);
        }
    }
    if (github == null) {
        github = GitHub.connect();
    }
    return github;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-build-status-notifier,代碼行數:22,代碼來源:GitHubProvider.java

示例3: 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

示例4: getLatestReleaseVersionOnGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * @return {@link GHRelease} corresponding to the latest release
 * @throws IOException In case there is an issue with the connection to GitHub
 */
private static GHRelease getLatestReleaseVersionOnGitHub() throws IOException
{
	// No credentials needed for reading
	GitHub github = GitHub.connect(null, null);
	
	// Retrieve the repo
	GHRepository repo = github.getUser("cd2357").getRepository("Moose");
	
	// Get the releases and associated tags
	List<GHRelease>			releases	= repo.listReleases().asList(); // list of releases
	Map<String, GHRelease>	releaseMap	= new HashMap<>(); // tag-to-release map
	List<String>			releaseTags	= new ArrayList<>(); // list of tags
	
	// Populate tag-to-release map and tag list
	for (GHRelease release : releases)
	{
		releaseMap.put(release.getTagName(), release);
		releaseTags.add(release.getTagName());
	}
	
	// Sort tags descending, so the first element is the biggest
	// Since the version numbers use the semantic versioning approach, it is enough to sort the string representation in order to sort the versions
	Collections.sort(releaseTags, Collections.reverseOrder());
	
	// Retrive the GHRelease with the highest tag (latest release)
	return releaseMap.get(releaseTags.get(0));
}
 
開發者ID:cd2357,項目名稱:Moose,代碼行數:32,代碼來源:Moose.java

示例5: connect

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private void connect() throws IOException{
	String accessToken = GhprbTrigger.getDscp().getAccessToken();
	String serverAPIUrl = GhprbTrigger.getDscp().getServerAPIUrl();
	if(accessToken != null && !accessToken.isEmpty()) {
		try {
			gh = GitHub.connectUsingOAuth(serverAPIUrl, accessToken);
		} catch(IOException e) {
			logger.log(Level.SEVERE, "Can''t connect to {0} using oauth", serverAPIUrl);
			throw e;
		}
	} else {
		gh = GitHub.connect(GhprbTrigger.getDscp().getUsername(), null, GhprbTrigger.getDscp().getPassword());
	}
}
 
開發者ID:ds2wang,項目名稱:ghprb-copy,代碼行數:15,代碼來源:GhprbGitHub.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: getSubmissionsFromRepo

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public JSONObject getSubmissionsFromRepo(String repoName) {
   LOGGER.info("Scanning Repo '" + repoName + "'.\n\n This might take some time!\n\n");
	JSONObject submissions;
   try {
           GitHub github = GitHub.connect(githubUser, githubToken);
		GHRepository repository = github.getRepository(repoName);
		testCases = getReferences(repository);
		submissions = getSubmissionsFromRootDir(repository);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
	LOGGER.info("done with scanning Repo '" + repoName + "'.");
	return submissions;
}
 
開發者ID:bpmn-miwg,項目名稱:bpmn-miwg-tools,代碼行數:15,代碼來源:RepoScanner.java

示例8: GitHubServiceImpl

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Autowired
public GitHubServiceImpl(UserRepository userRepository) throws IOException {
    this.github = GitHub.connect();
    this.userRepository = userRepository;
}
 
開發者ID:163yun,項目名稱:cloud-native-app-sample,代碼行數:6,代碼來源:GitHubServiceImpl.java

示例9: connect

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
protected static GitHub connect() throws IOException {
    return GitHub.connect();
}
 
開發者ID:centic9,項目名稱:github-version-statistics,代碼行數:4,代碼來源:BaseSearch.java


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