Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 975ef1a

Browse filesBrowse files
committed
Removed last traces of web client.
1 parent 7064865 commit 975ef1a
Copy full SHA for 975ef1a

File tree

Expand file treeCollapse file tree

6 files changed

+18
-51
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+18
-51
lines changed

‎.gitignore

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target
2+
.idea/
23
*.iml
34
*.ipr
45
*.iws

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,9 @@
4444

4545
<dependencies>
4646
<dependency>
47-
<groupId>org.jvnet.hudson</groupId>
48-
<artifactId>htmlunit</artifactId>
49-
<version>2.6-hudson-2</version>
50-
<exclusions>
51-
<exclusion>
52-
<!-- hides JDK DOM classes in Eclipse -->
53-
<groupId>xml-apis</groupId>
54-
<artifactId>xml-apis</artifactId>
55-
</exclusion>
56-
</exclusions>
47+
<groupId>commons-lang</groupId>
48+
<artifactId>commons-lang</artifactId>
49+
<version>2.6</version>
5750
</dependency>
5851
<dependency>
5952
<groupId>junit</groupId>

‎src/main/java/org/kohsuke/github/GHOrganization.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHOrganization.java
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package org.kohsuke.github;
22

3-
import com.gargoylesoftware.htmlunit.WebClient;
4-
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
5-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
6-
73
import java.io.IOException;
84
import java.util.AbstractList;
95
import java.util.ArrayList;
@@ -112,13 +108,12 @@ public GHTeam createTeam(String name, Permission p, GHRepository... repositories
112108
* List up repositories that has some open pull requests.
113109
*/
114110
public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException {
115-
WebClient wc = root.createWebClient();
116-
HtmlPage pg = (HtmlPage)wc.getPage("https://github.com/organizations/"+login+"/dashboard/pulls");
117111
List<GHRepository> r = new ArrayList<GHRepository>();
118-
for (HtmlAnchor e : pg.getElementById("js-issue-list").<HtmlAnchor>selectNodes(".//UL[@class='smallnav']/LI[not(@class='zeroed')]/A")) {
119-
String a = e.getHrefAttribute();
120-
String name = a.substring(a.lastIndexOf('/')+1);
121-
r.add(getRepository(name));
112+
for (GHRepository repository : root.retrieve().to("/orgs/" + login + "/repos", GHRepository[].class)) {
113+
List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN);
114+
if (pullRequests.size() > 0) {
115+
r.add(repository);
116+
}
122117
}
123118
return r;
124119
}

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+4-15Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
*/
2424
package org.kohsuke.github;
2525

26-
import com.gargoylesoftware.htmlunit.WebClient;
27-
import com.gargoylesoftware.htmlunit.html.HtmlButton;
28-
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
29-
import com.gargoylesoftware.htmlunit.html.HtmlForm;
30-
import com.gargoylesoftware.htmlunit.html.HtmlInput;
31-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
3226
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
3327

3428
import java.io.IOException;
@@ -266,15 +260,10 @@ private void modifyCollaborators(Collection<GHUser> users, String method) throws
266260
}
267261

268262
public void setEmailServiceHook(String address) throws IOException {
269-
WebClient wc = root.createWebClient();
270-
HtmlPage pg = (HtmlPage)wc.getPage(getUrl()+"/admin");
271-
HtmlInput email = (HtmlInput)pg.getElementById("email_address");
272-
email.setValueAttribute(address);
273-
HtmlCheckBoxInput active = (HtmlCheckBoxInput)pg.getElementById("email[active]");
274-
active.setChecked(true);
275-
276-
final HtmlForm f = email.getEnclosingFormOrDie();
277-
f.submit((HtmlButton) f.getElementsByTagName("button").get(0));
263+
Map<String, String> config = new HashMap<String, String>();
264+
config.put("address", address);
265+
new Requester(root).method("POST").with("name", "email").with("config", config).with("active", "true")
266+
.to(String.format("/repos/%s/%s/hooks", owner.login, name));
278267
}
279268

280269
private void edit(String key, String value) throws IOException {

‎src/main/java/org/kohsuke/github/GitHub.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHub.java
+1-16Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
*/
2424
package org.kohsuke.github;
2525

26-
import com.gargoylesoftware.htmlunit.WebClient;
27-
import com.gargoylesoftware.htmlunit.html.HtmlForm;
28-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
2926
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
3027
import org.apache.commons.io.IOUtils;
3128
import org.codehaus.jackson.map.DeserializationConfig.Feature;
@@ -273,7 +270,7 @@ public Map<String, GHOrganization> getMyOrganizations() throws IOException {
273270
* Public events visible to you. Equivalent of what's displayed on https://github.com/
274271
*/
275272
public List<GHEventInfo> getEvents() throws IOException {
276-
// TODO: pagenation
273+
// TODO: pagination
277274
GHEventInfo[] events = retrieve().to("/events", GHEventInfo[].class);
278275
for (GHEventInfo e : events)
279276
e.wrapUp(this);
@@ -318,18 +315,6 @@ public boolean isCredentialValid() throws IOException {
318315
}
319316
}
320317

321-
WebClient createWebClient() throws IOException {
322-
WebClient wc = new WebClient();
323-
wc.setJavaScriptEnabled(false);
324-
wc.setCssEnabled(false);
325-
HtmlPage pg = (HtmlPage)wc.getPage("https://github.com/login");
326-
HtmlForm f = pg.getForms().get(0);
327-
f.getInputByName("login").setValueAttribute(login);
328-
f.getInputByName("password").setValueAttribute(password);
329-
f.submit();
330-
return wc;
331-
}
332-
333318
/*package*/ static URL parseURL(String s) {
334319
try {
335320
return s==null ? null : new URL(s);

‎src/main/java/org/kohsuke/github/Requester.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/Requester.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ public Requester with(String key, Collection<String> value) {
107107
return _with(key, value);
108108
}
109109

110+
public Requester with(String key, Map<String, String> value) {
111+
return _with(key, value);
112+
}
113+
110114
public Requester _with(String key, Object value) {
111115
if (value!=null) {
112116
args.add(new Entry(key,value));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.