public PagedIterator<GHCommit> _iterator(int pageSize) { return new PagedIterator<GHCommit>(req.asIterator(repo.getApiTailUrl("commits"), GHCommit[].class, pageSize)) { protected void wrapUp(GHCommit[] page) { for (GHCommit c : page) c.wrapUp(repo); } }; } };
/** * List languages for the specified repository. * The value on the right of a language is the number of bytes of code written in that language. * { "C": 78769, "Python": 7769 } */ public Map<String,Long> listLanguages() throws IOException { return root.retrieve().to(getApiTailUrl("languages"), HashMap.class); }
public PagedIterator<GHRelease> _iterator(int pageSize) { return new PagedIterator<GHRelease>(root.retrieve().asIterator(getApiTailUrl("releases"), GHRelease[].class, pageSize)) { @Override protected void wrapUp(GHRelease[] page) { for (GHRelease c : page) c.wrap(GHRepository.this); } }; } };
/** * Gets the names of the collaborators on this repository. * This method deviates from the principle of this library but it works a lot faster than {@link #getCollaborators()}. */ public Set<String> getCollaboratorNames() throws IOException { Set<String> r = new HashSet<String>(); for (GHUser u : GHUser.wrap(root.retrieve().to(getApiTailUrl("collaborators"), GHUser[].class),root)) r.add(u.login); return r; }
public GHMilestone getMilestone(int number) throws IOException { GHMilestone m = milestones.get(number); if (m == null) { m = root.retrieve().to(getApiTailUrl("milestones/" + number), GHMilestone.class); m.owner = this; m.root = root; milestones.put(m.getNumber(), m); } return m; }
/** * Gets a comparison between 2 points in the repository. This would be similar * to calling <tt>git log id1...id2</tt> against a local repository. * @param id1 an identifier for the first point to compare from, this can be a sha1 ID (for a commit, tag etc) or a direct tag name * @param id2 an identifier for the second point to compare to. Can be the same as the first point. * @return the comparison output * @throws IOException on failure communicating with GitHub */ public GHCompare getCompare(String id1, String id2) throws IOException { GHCompare compare = root.retrieve().to(getApiTailUrl(String.format("compare/%s...%s", id1, id2)), GHCompare.class); return compare.wrap(this); }
/** * Gets branches by {@linkplain GHBranch#getName() their names}. */ public Map<String,GHBranch> getBranches() throws IOException { Map<String,GHBranch> r = new TreeMap<String,GHBranch>(); for (GHBranch p : root.retrieve().to(getApiTailUrl("branches"), GHBranch[].class)) { p.wrap(this); r.put(p.getName(),p); } return r; }
/** * Checks if the given user is an assignee for this repository. */ public boolean hasAssignee(GHUser u) throws IOException { return root.retrieve().asHttpStatusCode(getApiTailUrl("assignees/" + u.getLogin()))/100==2; }
public PagedIterator<GHRepository> _iterator(int pageSize) { return new PagedIterator<GHRepository>(root.retrieve().with("sort",sort).asIterator(getApiTailUrl("forks"), GHRepository[].class, pageSize)) { @Override protected void wrapUp(GHRepository[] page) { for (GHRepository c : page) { c.wrap(root); } } }; } };
/** * https://developer.github.com/v3/repos/contents/#get-the-readme */ public GHContent getReadme() throws IOException { Requester requester = root.retrieve(); return requester.to(getApiTailUrl("readme"), GHContent.class).wrap(this); }
/** * Deletes this release. */ public void delete() throws IOException { new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/"+id)); }
public PagedIterator<GHIssue> _iterator(int pageSize) { return new PagedIterator<GHIssue>(root.retrieve().with("state",state).asIterator(getApiTailUrl("issues"), GHIssue[].class, pageSize)) { @Override protected void wrapUp(GHIssue[] page) { for (GHIssue c : page) c.wrap(GHRepository.this); } }; } };
public GHRelease getLatestRelease() throws IOException { try { return root.retrieve().to(getApiTailUrl("releases/latest"), GHRelease.class).wrap(this); } catch (FileNotFoundException e) { return null; // no latest release } }
public void setEmailServiceHook(String address) throws IOException { Map<String, String> config = new HashMap<String, String>(); config.put("address", address); new Requester(root).method("POST").with("name", "email").with("config", config).with("active", true) .to(getApiTailUrl("hooks")); }
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(getApiTailUrl("")); }
@Preview @Deprecated private GHContentWithLicense getLicenseContent_() throws IOException { try { return root.retrieve() .withPreview(DRAX) .to(getApiTailUrl("license"), GHContentWithLicense.class).wrap(this); } catch (FileNotFoundException e) { return null; } }
public GHContent getFileContent(String path, String ref) throws IOException { Requester requester = root.retrieve(); String target = getApiTailUrl("contents/" + path); return requester.with("ref",ref).to(target, GHContent.class).wrap(this); }
/** * Obtain permission for a given user in this repository. * @param user a {@link GHUser#getLogin} * @throws FileNotFoundException under some conditions (e.g., private repo you can see but are not an admin of); treat as unknown * @throws HttpException with a 403 under other conditions (e.g., public repo you have no special rights to); treat as unknown */ public GHPermissionType getPermission(String user) throws IOException { GHPermission perm = root.retrieve().to(getApiTailUrl("collaborators/" + user + "/permission"), GHPermission.class); perm.wrapUp(root); return perm.getPermissionType(); }
/** * Commits a new content. */ public GHContentUpdateResponse commit() throws IOException { GHContentUpdateResponse response = req.to(repo.getApiTailUrl("contents/" + path), GHContentUpdateResponse.class); response.getContent().wrap(repo); response.getCommit().wrapUp(repo); return response; } }
public GHLabel createLabel(String name, String color) throws IOException { return root.retrieve().method("POST") .with("name",name) .with("color", color) .to(getApiTailUrl("labels"), GHLabel.class).wrapUp(this); }