mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-15 08:21:23 +00:00
Compare commits
3 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3080313aef | ||
|
|
0ddac59c9c | ||
|
|
131caf04e5 |
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
|||||||
<groupId>org.kohsuke</groupId>
|
<groupId>org.kohsuke</groupId>
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.1</version>
|
<version>1.2</version>
|
||||||
<name>GitHub API for Java</name>
|
<name>GitHub API for Java</name>
|
||||||
<url>http://kohsuke.org/github-api/</url>
|
<url>http://kohsuke.org/github-api/</url>
|
||||||
<description>GitHub API for Java</description>
|
<description>GitHub API for Java</description>
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ public class GHRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void modifyCollaborators(Collection<GHUser> users, String op) throws IOException {
|
private void modifyCollaborators(Collection<GHUser> users, String op) throws IOException {
|
||||||
root.requireCredential();
|
|
||||||
verifyMine();
|
verifyMine();
|
||||||
for (GHUser user : users) {
|
for (GHUser user : users) {
|
||||||
new Poster(root).withCredential().to(root.getApiURL("/repos/collaborators/"+name+ op +user.getLogin()));
|
new Poster(root).withCredential().to(root.getApiURL("/repos/collaborators/"+name+ op +user.getLogin()));
|
||||||
@@ -131,7 +130,6 @@ public class GHRepository {
|
|||||||
* Deletes this repository.
|
* Deletes this repository.
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
root.requireCredential();
|
|
||||||
verifyMine();
|
verifyMine();
|
||||||
Poster poster = new Poster(root).withCredential();
|
Poster poster = new Poster(root).withCredential();
|
||||||
URL url = root.getApiURL("/repos/delete/" + name);
|
URL url = root.getApiURL("/repos/delete/" + name);
|
||||||
@@ -140,6 +138,15 @@ public class GHRepository {
|
|||||||
poster.with("delete_token",token.delete_token).to(url);
|
poster.with("delete_token",token.delete_token).to(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forks this repository.
|
||||||
|
*/
|
||||||
|
public GHRepository fork() throws IOException {
|
||||||
|
GHRepository r = new Poster(root).withCredential().to(root.getApiURL("/repos/fork/" + owner + "/" + name), JsonRepository.class).repository;
|
||||||
|
r.root = root;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyMine() throws IOException {
|
private void verifyMine() throws IOException {
|
||||||
if (!root.login.equals(owner))
|
if (!root.login.equals(owner))
|
||||||
throw new IOException("Operation not applicable to a repository owned by someone else: "+owner);
|
throw new IOException("Operation not applicable to a repository owned by someone else: "+owner);
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ public class GitHub {
|
|||||||
* Newly created repository.
|
* Newly created repository.
|
||||||
*/
|
*/
|
||||||
public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) throws IOException {
|
public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) throws IOException {
|
||||||
requireCredential();
|
|
||||||
GHRepository r = new Poster(this).withCredential()
|
GHRepository r = new Poster(this).withCredential()
|
||||||
.with("name", name).with("description", description).with("homepage", homepage)
|
.with("name", name).with("description", description).with("homepage", homepage)
|
||||||
.with("public", isPublic ? 1 : 0).to(getApiURL("/repos/create"), JsonRepository.class).repository;
|
.with("public", isPublic ? 1 : 0).to(getApiURL("/repos/create"), JsonRepository.class).repository;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class Poster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Poster withCredential() {
|
public Poster withCredential() {
|
||||||
|
root.requireCredential();
|
||||||
return with("login",root.login).with("token",root.token);
|
return with("login",root.login).with("token",root.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user