Ejemplo n.º 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);
  }
Ejemplo n.º 2
0
 /** Creates a new team and assigns the repositories. */
 public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories)
     throws IOException {
   Requester post = new Requester(root).with("name", name).with("permission", p);
   List<String> repo_names = new ArrayList<String>();
   for (GHRepository r : repositories) {
     repo_names.add(r.getName());
   }
   post.with("repo_names", repo_names);
   return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
 }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
0
 private void edit(String key, String value) throws IOException {
   Requester requester = new Requester(root);
   if (!key.equals("name"))
     requester.with("name", name); // even when we don't change the name, we need to send it in
   requester.with(key, value).method("PATCH").to("/repos/" + owner.login + "/" + name);
 }