@Override public boolean equals(Object obj) { if (obj instanceof GHRepository) { GHRepository that = (GHRepository) obj; return this.getOwnerName().equals(that.getOwnerName()) && this.name.equals(that.name); } return false; }
@Override public int hashCode() { return ("Repository:"+getOwnerName()+":"+name).hashCode(); }
String getApiTailUrl(String tail) { if (tail.length()>0 && !tail.startsWith("/")) tail='/'+tail; return "/repos/" + getOwnerName() + "/" + name +tail; } }
String getApiTailUrl(String tail) { if (tail.length()>0 && !tail.startsWith("/")) tail='/'+tail; return "/repos/" + getOwnerName() + "/" + name +tail; } }
@Override String getApiRoute() { return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id); } }
public PagedIterator<GHCommit> _iterator(int pageSize) { return new PagedIterator<GHCommit>(root.retrieve().asIterator(String.format("/repos/%s/%s/commits", getOwnerName(), name), GHCommit[].class, pageSize)) { protected void wrapUp(GHCommit[] page) { for (GHCommit c : page) c.wrapUp(GHRepository.this); } }; } };
public PagedIterator<GHCommitComment> _iterator(int pageSize) { return new PagedIterator<GHCommitComment>(root.retrieve().asIterator(String.format("/repos/%s/%s/comments", getOwnerName(), name), GHCommitComment[].class, pageSize)) { @Override protected void wrapUp(GHCommitComment[] page) { for (GHCommitComment c : page) c.wrap(GHRepository.this); } }; } };
public PagedIterator<GHCommitStatus> _iterator(int pageSize) { return new PagedIterator<GHCommitStatus>(root.retrieve().asIterator(String.format("/repos/%s/%s/statuses/%s", getOwnerName(), name, sha1), GHCommitStatus[].class, pageSize)) { @Override protected void wrapUp(GHCommitStatus[] page) { for (GHCommitStatus c : page) c.wrapUp(root); } }; } };
public PagedIterator<GHCommitStatus> _iterator(int pageSize) { return new PagedIterator<GHCommitStatus>(root.retrieve().asIterator(String.format("/repos/%s/%s/statuses/%s", getOwnerName(), name, sha1), GHCommitStatus[].class, pageSize)) { @Override protected void wrapUp(GHCommitStatus[] page) { for (GHCommitStatus c : page) c.wrapUp(root); } }; } };
public PagedIterator<GHCommitComment> _iterator(int pageSize) { return new PagedIterator<GHCommitComment>(root.retrieve().asIterator(String.format("/repos/%s/%s/comments", getOwnerName(), name), GHCommitComment[].class, pageSize)) { @Override protected void wrapUp(GHCommitComment[] page) { for (GHCommitComment c : page) c.wrap(GHRepository.this); } }; } };
public PagedIterator<GHEventInfo> _iterator(int pageSize) { return new PagedIterator<GHEventInfo>(root.retrieve().asIterator(String.format("/repos/%s/%s/events", getOwnerName(), name), GHEventInfo[].class, pageSize)) { @Override protected void wrapUp(GHEventInfo[] page) { for (GHEventInfo c : page) c.wrapUp(root); } }; } };
/** * Gets a commit object in this repository. */ public GHCommit getCommit(String sha1) throws IOException { GHCommit c = commits.get(sha1); if (c==null) { c = root.retrieve().to(String.format("/repos/%s/%s/commits/%s", getOwnerName(), name, sha1), GHCommit.class).wrapUp(this); commits.put(sha1,c); } return c; }
public Iterator<ProjectConfigInfo> getRepositories() throws IOException { final String currentOrg = getCurrentOrg(); final Iterable<GHRepository> ghRepos = getCurrentUser().getRepositories(currentOrg); return StreamSupport.stream(ghRepos.spliterator(), false). filter(r -> r.hasAdminAccess() && currentOrg.equals(r.getOwnerName())).map(r -> new ProjectConfigInfo(r.getName(), r)).iterator(); }
/** * Retrieves all refs for the github repository. * @return an array of GHRef elements coresponding with the refs in the remote repository. * @throws IOException on failure communicating with GitHub */ public GHRef[] getRefs() throws IOException { return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), root); }
/** * Retrieves all refs of the given type for the current GitHub repository. * @param refType the type of reg to search for e.g. <tt>tags</tt> or <tt>commits</tt> * @return an array of all refs matching the request type * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested */ public GHRef[] getRefs(String refType) throws IOException { return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType), GHRef[].class),root); }
/** * Retrieves all refs for the github repository. * @return an array of GHRef elements coresponding with the refs in the remote repository. * @throws IOException on failure communicating with GitHub */ public GHRef[] getRefs() throws IOException { return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), root); }
public PagedIterator<GHCommitComment> _iterator(int pageSize) { return new PagedIterator<GHCommitComment>(owner.root.retrieve().asIterator(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha), GHCommitComment[].class, pageSize)) { @Override protected void wrapUp(GHCommitComment[] page) { for (GHCommitComment c : page) c.wrap(owner); } }; } };
/** * If this repository belongs to an organization, return a set of teams. */ public Set<GHTeam> getTeams() throws IOException { return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), root.getOrganization(getOwnerName()))))); }
/** * Deletes this hook. */ public void delete() throws IOException { new Requester(repository.root).method("DELETE").to(String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id)); }
public void add(GHRepository r, GHOrganization.Permission permission) throws IOException { org.root.retrieve().method("PUT") .with("permission", permission) .to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null); }