Пример #1
0
  public GHContent getFileContent(String path, String ref) throws IOException {
    Requester requester = root.retrieve();
    String target = String.format("/repos/%s/%s/contents/%s", owner.login, name, path);

    if (ref != null) target = target + "?ref=" + ref;

    return requester.to(target, GHContent.class).wrap(this);
  }
Пример #2
0
  public List<GHContent> getDirectoryContent(String path, String ref) throws IOException {
    Requester requester = root.retrieve();
    String target = String.format("/repos/%s/%s/contents/%s", owner.login, name, path);

    if (ref != null) target = target + "?ref=" + ref;

    GHContent[] files = requester.to(target, GHContent[].class);

    GHContent.wrap(files, this);

    return Arrays.asList(files);
  }
Пример #3
0
  public GHContentUpdateResponse createContent(
      String content, String commitMessage, String path, String branch) throws IOException {
    Requester requester =
        new Requester(root)
            .with("path", path)
            .with("message", commitMessage)
            .with("content", DatatypeConverter.printBase64Binary(content.getBytes()))
            .method("PUT");

    if (branch != null) {
      requester.with("branch", branch);
    }

    GHContentUpdateResponse response =
        requester.to(getApiTailUrl("contents/" + path), GHContentUpdateResponse.class);

    response.getContent().wrap(this);
    response.getCommit().wrapUp(this);

    return response;
  }
Пример #4
0
 public void to(String tailApiUrl) throws IOException {
     to(tailApiUrl,null);
 }