Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd58412

Browse files
committed
Merge pull request hub4j#19 from janinko/Issues-19-PagedIterable_dosnt_use_authentication
PagedIterable dosn't use authentication
2 parents 5210870 + e658a7f commit bd58412

File tree

12 files changed

+39
-43
lines changed

12 files changed

+39
-43
lines changed

src/main/java/org/kohsuke/github/GHCommit.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ public GHCommitComment createComment(String body, String path, Integer line, Int
225225
.with("path",path)
226226
.with("line",line)
227227
.with("position",position)
228-
.withCredential()
229228
.to(String.format("/repos/%s/%s/commits/%s/comments",owner.getOwnerName(),owner.getName(),sha),GHCommitComment.class);
230229
return r.wrap(owner);
231230
}

src/main/java/org/kohsuke/github/GHCommitComment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ public GHCommit getCommit() throws IOException {
9999
public void update(String body) throws IOException {
100100
GHCommitComment r = new Requester(owner.root)
101101
.with("body", body)
102-
.withCredential().method("PATCH").to(getApiTail(), GHCommitComment.class);
102+
.method("PATCH").to(getApiTail(), GHCommitComment.class);
103103
this.body = body;
104104
}
105105

106106
/**
107107
* Deletes this comment.
108108
*/
109109
public void delete() throws IOException {
110-
new Requester(owner.root).withCredential().method("DELETE").to(getApiTail());
110+
new Requester(owner.root).method("DELETE").to(getApiTail());
111111
}
112112

113113
private String getApiTail() {

src/main/java/org/kohsuke/github/GHHook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public int getId() {
5454
* Deletes this hook.
5555
*/
5656
public void delete() throws IOException {
57-
new Requester(repository.root).withCredential().method("DELETE").to(String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id));
57+
new Requester(repository.root).method("DELETE").to(String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id));
5858
}
5959
}

src/main/java/org/kohsuke/github/GHIssue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ public URL getApiURL(){
138138
* Updates the issue by adding a comment.
139139
*/
140140
public void comment(String message) throws IOException {
141-
new Requester(root).withCredential().with("body",message).to(getApiRoute() + "/comments");
141+
new Requester(root).with("body",message).to(getApiRoute() + "/comments");
142142
}
143143

144144
private void edit(String key, Object value) throws IOException {
145-
new Requester(root).withCredential()._with(key, value).method("PATCH").to(getApiRoute());
145+
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
146146
}
147147

148148
/**

src/main/java/org/kohsuke/github/GHMyself.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class GHMyself extends GHUser {
2222
* Always non-null.
2323
*/
2424
public List<String> getEmails() throws IOException {
25-
String[] addresses = root.retrieve().withCredential().to("/user/emails", String[].class);
25+
String[] addresses = root.retrieve().to("/user/emails", String[].class);
2626
return Collections.unmodifiableList(Arrays.asList(addresses));
2727
}
2828

@@ -33,7 +33,7 @@ public List<String> getEmails() throws IOException {
3333
* Always non-null.
3434
*/
3535
public List<GHKey> getPublicKeys() throws IOException {
36-
return Collections.unmodifiableList(Arrays.asList(root.retrieve().withCredential().to("/user/keys", GHKey[].class)));
36+
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/user/keys", GHKey[].class)));
3737
}
3838

3939
// public void addEmails(Collection<String> emails) throws IOException {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public GHRepository createRepository(String name, String description, String hom
3333

3434
public GHRepository createRepository(String name, String description, String homepage, GHTeam team, boolean isPublic) throws IOException {
3535
// such API doesn't exist, so fall back to HTML scraping
36-
return new Requester(root).withCredential()
36+
return new Requester(root)
3737
.with("name", name).with("description", description).with("homepage", homepage)
3838
.with("public", isPublic).with("team_id",team.getId()).to("/orgs/"+login+"/repos", GHRepository.class).wrap(root);
3939
}
@@ -42,7 +42,7 @@ public GHRepository createRepository(String name, String description, String hom
4242
* Teams by their names.
4343
*/
4444
public Map<String,GHTeam> getTeams() throws IOException {
45-
GHTeam[] teams = root.retrieve().withCredential().to("/orgs/" + login + "/teams", GHTeam[].class);
45+
GHTeam[] teams = root.retrieve().to("/orgs/" + login + "/teams", GHTeam[].class);
4646
Map<String,GHTeam> r = new TreeMap<String, GHTeam>();
4747
for (GHTeam t : teams) {
4848
r.put(t.getName(),t.wrapUp(this));
@@ -54,7 +54,7 @@ public Map<String,GHTeam> getTeams() throws IOException {
5454
* Publicizes the membership.
5555
*/
5656
public void publicize(GHUser u) throws IOException {
57-
root.retrieve().withCredential().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
57+
root.retrieve().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
5858
}
5959

6060
/**
@@ -64,7 +64,7 @@ public List<GHUser> getMembers() throws IOException {
6464
return new AbstractList<GHUser>() {
6565
// these are shallow objects with only some limited values filled out
6666
// TODO: it's better to allow objects to fill themselves in later when missing values are requested
67-
final GHUser[] shallow = root.retrieve().withCredential().to("/orgs/" + login + "/members", GHUser[].class);
67+
final GHUser[] shallow = root.retrieve().to("/orgs/" + login + "/members", GHUser[].class);
6868

6969
@Override
7070
public GHUser get(int index) {
@@ -86,7 +86,7 @@ public int size() {
8686
* Conceals the membership.
8787
*/
8888
public void conceal(GHUser u) throws IOException {
89-
root.retrieve().withCredential().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
89+
root.retrieve().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
9090
}
9191

9292
public enum Permission { ADMIN, PUSH, PULL }
@@ -95,7 +95,7 @@ public enum Permission { ADMIN, PUSH, PULL }
9595
* Creates a new team and assigns the repositories.
9696
*/
9797
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
98-
Requester post = new Requester(root).withCredential().with("name", name).with("permission", p.name().toLowerCase());
98+
Requester post = new Requester(root).with("name", name).with("permission", p.name().toLowerCase());
9999
List<String> repo_names = new ArrayList<String>();
100100
for (GHRepository r : repositories) {
101101
repo_names.add(r.getName());

src/main/java/org/kohsuke/github/GHPerson.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void remove() {
9696
*/
9797
public GHRepository getRepository(String name) throws IOException {
9898
try {
99-
return root.retrieve().withCredential().to("/repos/" + login + '/' + name, GHRepository.class).wrap(root);
99+
return root.retrieve().to("/repos/" + login + '/' + name, GHRepository.class).wrap(root);
100100
} catch (FileNotFoundException e) {
101101
return null;
102102
}

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public Set<String> getCollaboratorNames() throws IOException {
231231
* If this repository belongs to an organization, return a set of teams.
232232
*/
233233
public Set<GHTeam> getTeams() throws IOException {
234-
return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().withCredential().to("/repos/" + owner.login + "/" + name + "/teams", GHTeam[].class), root.getOrganization(owner.login)))));
234+
return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().to("/repos/" + owner.login + "/" + name + "/teams", GHTeam[].class), root.getOrganization(owner.login)))));
235235
}
236236

237237
public void addCollaborators(GHUser... users) throws IOException {
@@ -253,7 +253,7 @@ public void removeCollaborators(Collection<GHUser> users) throws IOException {
253253
private void modifyCollaborators(Collection<GHUser> users, String method) throws IOException {
254254
verifyMine();
255255
for (GHUser user : users) {
256-
new Requester(root).withCredential().method(method).to("/repos/" + owner.login + "/" + name + "/collaborators/" + user.getLogin());
256+
new Requester(root).method(method).to("/repos/" + owner.login + "/" + name + "/collaborators/" + user.getLogin());
257257
}
258258
}
259259

@@ -270,7 +270,7 @@ public void setEmailServiceHook(String address) throws IOException {
270270
}
271271

272272
private void edit(String key, String value) throws IOException {
273-
Requester requester = new Requester(root).withCredential();
273+
Requester requester = new Requester(root);
274274
if (!key.equals("name"))
275275
requester.with("name", name); // even when we don't change the name, we need to send it in
276276
requester.with(key, value).method("PATCH").to("/repos/" + owner.login + "/" + name);
@@ -313,7 +313,7 @@ public void setHomepage(String value) throws IOException {
313313
* Deletes this repository.
314314
*/
315315
public void delete() throws IOException {
316-
new Requester(root).withCredential().method("DELETE").to("/repos/" + owner.login + "/" + name);
316+
new Requester(root).method("DELETE").to("/repos/" + owner.login + "/" + name);
317317
}
318318

319319
/**
@@ -323,7 +323,7 @@ public void delete() throws IOException {
323323
* Newly forked repository that belong to you.
324324
*/
325325
public GHRepository fork() throws IOException {
326-
return new Requester(root).withCredential().method("POST").to("/repos/" + owner.login + "/" + name + "/forks", GHRepository.class).wrap(root);
326+
return new Requester(root).method("POST").to("/repos/" + owner.login + "/" + name + "/forks", GHRepository.class).wrap(root);
327327
}
328328

329329
/**
@@ -333,7 +333,7 @@ public GHRepository fork() throws IOException {
333333
* Newly forked repository that belong to you.
334334
*/
335335
public GHRepository forkTo(GHOrganization org) throws IOException {
336-
new Requester(root).withCredential().to(String.format("/repos/%s/%s/forks?org=%s",owner.login,name,org.getLogin()));
336+
new Requester(root).to(String.format("/repos/%s/%s/forks?org=%s",owner.login,name,org.getLogin()));
337337

338338
// this API is asynchronous. we need to wait for a bit
339339
for (int i=0; i<10; i++) {
@@ -352,7 +352,7 @@ public GHRepository forkTo(GHOrganization org) throws IOException {
352352
* Retrieves a specified pull request.
353353
*/
354354
public GHPullRequest getPullRequest(int i) throws IOException {
355-
return root.retrieve().withCredential().to("/repos/" + owner.login + '/' + name + "/pulls/" + i, GHPullRequest.class).wrapUp(this);
355+
return root.retrieve().to("/repos/" + owner.login + '/' + name + "/pulls/" + i, GHPullRequest.class).wrapUp(this);
356356
}
357357

358358
/**
@@ -386,14 +386,14 @@ protected void wrapUp(GHPullRequest[] page) {
386386
*/
387387
public List<GHHook> getHooks() throws IOException {
388388
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(
389-
root.retrieve().withCredential().to(String.format("/repos/%s/%s/hooks", owner.login, name), GHHook[].class)));
389+
root.retrieve().to(String.format("/repos/%s/%s/hooks", owner.login, name), GHHook[].class)));
390390
for (GHHook h : list)
391391
h.wrap(this);
392392
return list;
393393
}
394394

395395
public GHHook getHook(int id) throws IOException {
396-
return root.retrieve().withCredential().to(String.format("/repos/%s/%s/hooks/%d", owner.login, name, id), GHHook.class).wrap(this);
396+
return root.retrieve().to(String.format("/repos/%s/%s/hooks/%d", owner.login, name, id), GHHook.class).wrap(this);
397397
}
398398

399399
/**
@@ -476,7 +476,6 @@ public GHCommitStatus getLastCommitStatus(String sha1) throws IOException {
476476
*/
477477
public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException {
478478
return new Requester(root)
479-
.withCredential()
480479
.with("state",state.name().toLowerCase(Locale.ENGLISH))
481480
.with("target_url", targetUrl)
482481
.with("description", description)
@@ -505,7 +504,6 @@ public GHHook createHook(String name, Map<String,String> config, Collection<GHEv
505504
}
506505

507506
return new Requester(root)
508-
.withCredential()
509507
.with("name",name)
510508
.with("active", active)
511509
._with("config", config)
@@ -640,7 +638,7 @@ public GHMilestone getMilestone(int number) throws IOException {
640638
}
641639

642640
public GHMilestone createMilestone(String title, String description) throws IOException {
643-
return new Requester(root).withCredential()
641+
return new Requester(root)
644642
.with("title", title).with("description", description).method("POST").to("/repos/" + owner.login + "/" + name + "/milestones", GHMilestone.class).wrap(this);
645643
}
646644

src/main/java/org/kohsuke/github/GHTeam.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public int getId() {
4646
* Retrieves the current members.
4747
*/
4848
public Set<GHUser> getMembers() throws IOException {
49-
return new HashSet<GHUser>(Arrays.asList(GHUser.wrap(org.root.retrieve().withCredential().to(api("/members"), GHUser[].class), org.root)));
49+
return new HashSet<GHUser>(Arrays.asList(GHUser.wrap(org.root.retrieve().to(api("/members"), GHUser[].class), org.root)));
5050
}
5151

5252
public Map<String,GHRepository> getRepositories() throws IOException {
53-
GHRepository[] repos = org.root.retrieve().withCredential().to(api("/repos"), GHRepository[].class);
53+
GHRepository[] repos = org.root.retrieve().to(api("/repos"), GHRepository[].class);
5454
Map<String,GHRepository> m = new TreeMap<String, GHRepository>();
5555
for (GHRepository r : repos) {
5656
m.put(r.getName(),r.wrap(org.root));
@@ -62,22 +62,22 @@ public Map<String,GHRepository> getRepositories() throws IOException {
6262
* Adds a member to the team.
6363
*/
6464
public void add(GHUser u) throws IOException {
65-
org.root.retrieve().withCredential().method("PUT").to(api("/members/" + u.getLogin()), null);
65+
org.root.retrieve().method("PUT").to(api("/members/" + u.getLogin()), null);
6666
}
6767

6868
/**
6969
* Removes a member to the team.
7070
*/
7171
public void remove(GHUser u) throws IOException {
72-
org.root.retrieve().withCredential().method("DELETE").to(api("/members/" + u.getLogin()), null);
72+
org.root.retrieve().method("DELETE").to(api("/members/" + u.getLogin()), null);
7373
}
7474

7575
public void add(GHRepository r) throws IOException {
76-
org.root.retrieve().withCredential().method("PUT").to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null);
76+
org.root.retrieve().method("PUT").to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null);
7777
}
7878

7979
public void remove(GHRepository r) throws IOException {
80-
org.root.retrieve().withCredential().method("DELETE").to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null);
80+
org.root.retrieve().method("DELETE").to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null);
8181
}
8282

8383
private String api(String tail) {

src/main/java/org/kohsuke/github/GHUser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public class GHUser extends GHPerson {
4141
* Follow this user.
4242
*/
4343
public void follow() throws IOException {
44-
new Requester(root).withCredential().method("PUT").to("/user/following/" + login);
44+
new Requester(root).method("PUT").to("/user/following/" + login);
4545
}
4646

4747
/**
4848
* Unfollow this user.
4949
*/
5050
public void unfollow() throws IOException {
51-
new Requester(root).withCredential().method("DELETE").to("/user/following/" + login);
51+
new Requester(root).method("DELETE").to("/user/following/" + login);
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)