本文整理匯總了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();
}
}
示例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;
}
示例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);
}
示例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));
}
示例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());
}
}
示例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: 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;
}
示例8: GitHubServiceImpl
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Autowired
public GitHubServiceImpl(UserRepository userRepository) throws IOException {
this.github = GitHub.connect();
this.userRepository = userRepository;
}
示例9: connect
import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
protected static GitHub connect() throws IOException {
return GitHub.connect();
}