Compare commits

...

3 Commits

Author SHA1 Message Date
Kohsuke Kawaguchi
3080313aef [maven-release-plugin] prepare release github-api-1.2 2010-04-19 09:38:20 -07:00
Kohsuke Kawaguchi
0ddac59c9c added the fork support 2010-04-19 09:27:44 -07:00
Kohsuke Kawaguchi
131caf04e5 [maven-release-plugin] prepare for next development iteration 2010-04-18 22:24:12 -07:00
4 changed files with 11 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
<version>1.2</version>
<name>GitHub API for Java</name>
<url>http://kohsuke.org/github-api/</url>
<description>GitHub API for Java</description>

View File

@@ -120,7 +120,6 @@ public class GHRepository {
}
private void modifyCollaborators(Collection<GHUser> users, String op) throws IOException {
root.requireCredential();
verifyMine();
for (GHUser user : users) {
new Poster(root).withCredential().to(root.getApiURL("/repos/collaborators/"+name+ op +user.getLogin()));
@@ -131,7 +130,6 @@ public class GHRepository {
* Deletes this repository.
*/
public void delete() throws IOException {
root.requireCredential();
verifyMine();
Poster poster = new Poster(root).withCredential();
URL url = root.getApiURL("/repos/delete/" + name);
@@ -140,6 +138,15 @@ public class GHRepository {
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 {
if (!root.login.equals(owner))
throw new IOException("Operation not applicable to a repository owned by someone else: "+owner);

View File

@@ -125,7 +125,6 @@ public class GitHub {
* Newly created repository.
*/
public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) throws IOException {
requireCredential();
GHRepository r = new Poster(this).withCredential()
.with("name", name).with("description", description).with("homepage", homepage)
.with("public", isPublic ? 1 : 0).to(getApiURL("/repos/create"), JsonRepository.class).repository;

View File

@@ -51,6 +51,7 @@ class Poster {
}
public Poster withCredential() {
root.requireCredential();
return with("login",root.login).with("token",root.token);
}