// 2. Get branch/commit hash for the source repo - the actual source code
  @Test
  public void existsInGit() throws IOException {
    final String repo = "binrepo-devex";
    //  final String repo = "search_raptor_binary";
    String githubUrl = "https://github.scm.corp.ebay.com/api/v3/";
    String accessToken = "1cf7d9792235b8592eda18bd7dcc2de37f99b3bc";
    // String accessToken = "5d8e186b08062ca405ab25d489fca9823c2a7136";

    GitHub gitHub = GitHub.connectUsingOAuth(githubUrl, accessToken);

    String login = gitHub.getMyself().getLogin();
    System.out.println(login);

    GHRepository repository = gitHub.getMyself().getRepository(repo);
    if (repository != null) {
      System.out.println(repository.getDescription());
      Map<String, GHBranch> branches = repository.getBranches();
      for (String branch : branches.keySet()) {
        System.out.println(branch);

        GHBranch ghBranch = branches.get(branch);

        System.out.println(
            "Repository URL = "
                + repository.getUrl()
                + " Branch = "
                + ghBranch.getName()
                + " Commit Hash = "
                + ghBranch.getSHA1());
      }

      PagedIterable<GHCommit> commits = repository.listCommits();
      for (GHCommit commit : commits) {
        List<GHCommit.File> commitFiles = commit.getFiles();
        for (GHCommit.File commitFile : commitFiles) {
          System.out.println(commitFile.getFileName() + commitFile.getRawUrl());
        }
        System.out.println(
            commit.getSHA1()
                + " NumFiles = "
                + commit.getFiles().size()
                + " Committer = "
                + commit.getCommitter().getName()); // + commit.getLastStatus().getDescription());
      }

      GHBranch test2 = branches.get("test2");
      test2.getRoot();
    }
  }
Ejemplo n.º 2
0
 public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException {
   return getCompare(id1.getSHA1(), id2.getSHA1());
 }