mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-17 15:50:20 +00:00
Compare commits
11 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b953d0c831 | ||
|
|
ecb71006d8 | ||
|
|
cffa552ba1 | ||
|
|
f6e7ee3253 | ||
|
|
275b55f674 | ||
|
|
d3a18d234f | ||
|
|
ab2d0cebaf | ||
|
|
878468820b | ||
|
|
6c9ebd1b5f | ||
|
|
985a11d896 | ||
|
|
c6712ed6d5 |
28
pom.xml
28
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.5</version>
|
<version>1.7</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>
|
||||||
@@ -19,6 +19,32 @@
|
|||||||
</site>
|
</site>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>m.g.o-public</id>
|
||||||
|
<url>http://maven.glassfish.org/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>m.g.o-public</id>
|
||||||
|
<url>http://maven.glassfish.org/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -43,11 +43,15 @@ public abstract class GHPerson {
|
|||||||
*/
|
*/
|
||||||
protected GHRepository refreshRepository(String name) throws IOException {
|
protected GHRepository refreshRepository(String name) throws IOException {
|
||||||
if (repositories==null) getRepositories(); // fetch the base first
|
if (repositories==null) getRepositories(); // fetch the base first
|
||||||
GHRepository r = root.retrieve("/repos/show/" + login + '/' + name, JsonRepository.class).wrap(root);
|
GHRepository r = fetchRepository(name);
|
||||||
repositories.put(name,r);
|
repositories.put(name,r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GHRepository fetchRepository(String name) throws IOException {
|
||||||
|
return root.retrieve("/repos/show/" + login + '/' + name, JsonRepository.class).wrap(root);
|
||||||
|
}
|
||||||
|
|
||||||
public GHRepository getRepository(String name) throws IOException {
|
public GHRepository getRepository(String name) throws IOException {
|
||||||
return getRepositories().get(name);
|
return getRepositories().get(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,15 @@ package org.kohsuke.github;
|
|||||||
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
|
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
|
||||||
import com.gargoylesoftware.htmlunit.WebClient;
|
import com.gargoylesoftware.htmlunit.WebClient;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlButton;
|
import com.gargoylesoftware.htmlunit.html.HtmlButton;
|
||||||
|
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
|
||||||
|
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -165,6 +169,18 @@ public class GHRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEmailServiceHook(String address) throws IOException {
|
||||||
|
WebClient wc = root.createWebClient();
|
||||||
|
HtmlPage pg = (HtmlPage)wc.getPage(getUrl()+"/admin");
|
||||||
|
HtmlInput email = (HtmlInput)pg.getElementById("Email_address");
|
||||||
|
email.setValueAttribute(address);
|
||||||
|
HtmlCheckBoxInput active = (HtmlCheckBoxInput)pg.getElementById("Email[active]");
|
||||||
|
active.setChecked(true);
|
||||||
|
|
||||||
|
final HtmlForm f = email.getEnclosingFormOrDie();
|
||||||
|
f.submit((HtmlButton)f.getElementsByTagName("button").get(0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this repository.
|
* Deletes this repository.
|
||||||
*/
|
*/
|
||||||
@@ -222,7 +238,19 @@ public class GHRepository {
|
|||||||
try {
|
try {
|
||||||
f.getInputByName("name").setValueAttribute(newName);
|
f.getInputByName("name").setValueAttribute(newName);
|
||||||
f.submit((HtmlButton)f.getElementsByTagName("button").get(0));
|
f.submit((HtmlButton)f.getElementsByTagName("button").get(0));
|
||||||
name = newName;
|
|
||||||
|
// overwrite fields
|
||||||
|
final GHRepository r = getOwner().fetchRepository(newName);
|
||||||
|
for (Field fi : getClass().getDeclaredFields()) {
|
||||||
|
if (Modifier.isStatic(fi.getModifiers())) continue;
|
||||||
|
fi.setAccessible(true);
|
||||||
|
try {
|
||||||
|
fi.set(this,fi.get(r));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw (IllegalAccessError)new IllegalAccessError().initCause(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (ElementNotFoundException e) {
|
} catch (ElementNotFoundException e) {
|
||||||
// continue
|
// continue
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public class AppTest extends TestCase {
|
|||||||
public void testApp() throws IOException {
|
public void testApp() throws IOException {
|
||||||
GitHub gitHub = GitHub.connect();
|
GitHub gitHub = GitHub.connect();
|
||||||
|
|
||||||
|
// gitHub.getMyself().getRepository("perforce-plugin").setEmailServiceHook("kk@kohsuke.org");
|
||||||
|
|
||||||
// tryRenaming(gitHub);
|
// tryRenaming(gitHub);
|
||||||
// tryOrgFork(gitHub);
|
// tryOrgFork(gitHub);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user