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 1e497d2

Browse filesBrowse files
authored
Merge branch 'master' into bridge-method-annotation
2 parents 09c2b39 + 70bd4fa commit 1e497d2
Copy full SHA for 1e497d2
Expand file treeCollapse file tree

16 files changed

+238
-57
lines changed

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</parent>
88

99
<artifactId>github-api</artifactId>
10-
<version>1.90-SNAPSHOT</version>
10+
<version>1.91-SNAPSHOT</version>
1111
<name>GitHub API for Java</name>
1212
<url>http://github-api.kohsuke.org/</url>
1313
<description>GitHub API for Java</description>
@@ -64,7 +64,7 @@
6464
<plugin>
6565
<groupId>com.infradna.tool</groupId>
6666
<artifactId>bridge-method-injector</artifactId>
67-
<version>1.14</version>
67+
<version>1.18</version>
6868
<executions>
6969
<execution>
7070
<goals>
@@ -108,7 +108,7 @@
108108
<dependency>
109109
<groupId>junit</groupId>
110110
<artifactId>junit</artifactId>
111-
<version>4.11</version>
111+
<version>4.12</version>
112112
<scope>test</scope>
113113
</dependency>
114114
<dependency>
@@ -120,7 +120,7 @@
120120
<dependency>
121121
<groupId>com.fasterxml.jackson.core</groupId>
122122
<artifactId>jackson-databind</artifactId>
123-
<version>2.2.3</version>
123+
<version>2.9.2</version>
124124
</dependency>
125125
<dependency>
126126
<groupId>commons-io</groupId>
@@ -130,7 +130,7 @@
130130
<dependency>
131131
<groupId>com.infradna.tool</groupId>
132132
<artifactId>bridge-method-annotation</artifactId>
133-
<version>1.14</version>
133+
<version>1.17</version>
134134
<optional>true</optional>
135135
</dependency>
136136
<dependency>
@@ -142,7 +142,7 @@
142142
<dependency>
143143
<groupId>org.eclipse.jgit</groupId>
144144
<artifactId>org.eclipse.jgit</artifactId>
145-
<version>3.1.0.201310021548-r</version>
145+
<version>4.9.0.201710071750-r</version>
146146
<scope>test</scope>
147147
</dependency>
148148
<dependency>
@@ -154,25 +154,25 @@
154154
<dependency>
155155
<groupId>com.squareup.okhttp3</groupId>
156156
<artifactId>okhttp-urlconnection</artifactId>
157-
<version>3.4.0</version>
157+
<version>3.9.0</version>
158158
<optional>true</optional>
159159
</dependency>
160160
<dependency>
161161
<groupId>org.kohsuke</groupId>
162162
<artifactId>wordnet-random-name</artifactId>
163-
<version>1.2</version>
163+
<version>1.3</version>
164164
<scope>test</scope>
165165
</dependency>
166166
<dependency>
167167
<groupId>org.mockito</groupId>
168168
<artifactId>mockito-all</artifactId>
169-
<version>1.9.5</version>
169+
<version>1.10.19</version>
170170
<scope>test</scope>
171171
</dependency>
172172
<dependency>
173173
<groupId>com.google.code.findbugs</groupId>
174174
<artifactId>annotations</artifactId>
175-
<version>3.0.0</version>
175+
<version>3.0.1</version>
176176
<scope>provided</scope>
177177
</dependency>
178178
</dependencies>

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java
+26-2Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class GHCreateRepositoryBuilder {
2121
}
2222

2323
public GHCreateRepositoryBuilder description(String description) {
24-
this.builder.with("description",description);
25-
return this;
24+
this.builder.with("description",description);
25+
return this;
2626
}
2727

2828
public GHCreateRepositoryBuilder homepage(URL homepage) {
@@ -74,6 +74,30 @@ public GHCreateRepositoryBuilder autoInit(boolean b) {
7474
return this;
7575
}
7676

77+
/**
78+
* Allow or disallow squash-merging pull requests.
79+
*/
80+
public GHCreateRepositoryBuilder allowSquashMerge(boolean b) {
81+
this.builder.with("allow_squash_merge",b);
82+
return this;
83+
}
84+
85+
/**
86+
* Allow or disallow merging pull requests with a merge commit.
87+
*/
88+
public GHCreateRepositoryBuilder allowMergeCommit(boolean b) {
89+
this.builder.with("allow_merge_commit",b);
90+
return this;
91+
}
92+
93+
/**
94+
* Allow or disallow rebase-merging pull requests.
95+
*/
96+
public GHCreateRepositoryBuilder allowRebaseMerge(boolean b) {
97+
this.builder.with("allow_rebase_merge",b);
98+
return this;
99+
}
100+
77101
/**
78102
* Creates a default .gitignore
79103
*

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHDeployment.java
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import java.io.IOException;
44
import java.net.URL;
55

6+
/**
7+
* Represents a deployment
8+
*
9+
* @see <a href="https://developer.github.com/v3/repos/deployments/">documentation</a>
10+
* @see GHRepository#listDeployments(String, String, String, String)
11+
* @see GHRepository#getDeployment(long)
12+
*/
613
public class GHDeployment extends GHObject {
714
private GHRepository owner;
815
private GitHub root;
@@ -58,4 +65,23 @@ public String getSha(){
5865
public URL getHtmlUrl() {
5966
return null;
6067
}
68+
69+
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
70+
return new GHDeploymentStatusBuilder(owner,id,state);
71+
}
72+
73+
public PagedIterable<GHDeploymentStatus> listStatuses() {
74+
return new PagedIterable<GHDeploymentStatus>() {
75+
public PagedIterator<GHDeploymentStatus> _iterator(int pageSize) {
76+
return new PagedIterator<GHDeploymentStatus>(root.retrieve().asIterator(statuses_url, GHDeploymentStatus[].class, pageSize)) {
77+
@Override
78+
protected void wrapUp(GHDeploymentStatus[] page) {
79+
for (GHDeploymentStatus c : page)
80+
c.wrap(owner);
81+
}
82+
};
83+
}
84+
};
85+
}
86+
6187
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
import java.io.IOException;
44

5+
/**
6+
* Creates a new deployment status.
7+
*
8+
* @see
9+
* GHDeployment#createStatus(GHDeploymentState)
10+
*/
511
public class GHDeploymentStatusBuilder {
612
private final Requester builder;
713
private GHRepository repo;
8-
private int deploymentId;
14+
private long deploymentId;
915

16+
/**
17+
* @deprecated
18+
* Use {@link GHDeployment#createStatus(GHDeploymentState)}
19+
*/
1020
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
21+
this(repo,(long)deploymentId,state);
22+
}
23+
24+
/*package*/ GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
1125
this.repo = repo;
1226
this.deploymentId = deploymentId;
1327
this.builder = new Requester(repo.root);
@@ -25,6 +39,6 @@ public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
2539
}
2640

2741
public GHDeploymentStatus create() throws IOException {
28-
return builder.to(repo.getApiTailUrl("deployments")+"/"+deploymentId+"/statuses",GHDeploymentStatus.class).wrap(repo);
42+
return builder.to(repo.getApiTailUrl("deployments/"+deploymentId+"/statuses"),GHDeploymentStatus.class).wrap(repo);
2943
}
3044
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHGist.java
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Map<String,GHGistFile> getFiles() {
103103
* Used when caller obtains {@link GHGist} without knowing its owner.
104104
* A partially constructed owner object is interned.
105105
*/
106-
/*package*/ GHGist wrapUp(GitHub root) throws IOException {
106+
/*package*/ GHGist wrapUp(GitHub root) {
107107
this.owner = root.getUser(owner);
108108
this.root = root;
109109
wrapUp();
@@ -144,12 +144,8 @@ public PagedIterator<GHGist> _iterator(int pageSize) {
144144
return new PagedIterator<GHGist>(root.retrieve().asIterator(getApiTailUrl("forks"), GHGist[].class, pageSize)) {
145145
@Override
146146
protected void wrapUp(GHGist[] page) {
147-
try {
148-
for (GHGist c : page)
149-
c.wrapUp(root);
150-
} catch (IOException e) {
151-
throw new Error(e);
152-
}
147+
for (GHGist c : page)
148+
c.wrapUp(root);
153149
}
154150
};
155151
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssue.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ public void setBody(String body) throws IOException {
203203
edit("body",body);
204204
}
205205

206+
public void setMilestone(GHMilestone milestone) throws IOException {
207+
edit("milestone",milestone.getNumber());
208+
}
209+
206210
public void assignTo(GHUser user) throws IOException {
207211
setAssignees(user);
208212
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHLabel.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ public String getColor() {
3434
public void delete() throws IOException {
3535
repo.root.retrieve().method("DELETE").to(url);
3636
}
37+
38+
/**
39+
* @param newColor
40+
* 6-letter hex color code, like "f29513"
41+
*/
42+
public void setColor(String newColor) throws IOException {
43+
repo.root.retrieve().method("PATCH").with("name", name).with("color", newColor).to(url);
44+
}
3745
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHObject.java
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public abstract class GHObject {
2525
protected Map<String, List<String>> responseHeaderFields;
2626

2727
protected String url;
28-
protected int id;
28+
protected long id;
2929
protected String created_at;
3030
protected String updated_at;
3131

@@ -84,14 +84,18 @@ public Date getUpdatedAt() throws IOException {
8484
/**
8585
* Unique ID number of this resource.
8686
*/
87-
@WithBridgeMethods(value=String.class, adapterMethod="intToString")
88-
public int getId() {
87+
@WithBridgeMethods(value={String.class,int.class}, adapterMethod="longToStringOrInt")
88+
public long getId() {
8989
return id;
9090
}
9191

9292
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getId")
93-
private Object intToString(int id, Class type) {
94-
return String.valueOf(id);
93+
private Object longToStringOrInt(long id, Class type) {
94+
if (type==String.class)
95+
return String.valueOf(id);
96+
if (type==int.class)
97+
return (int)id;
98+
throw new AssertionError("Unexpected type: "+type);
9599
}
96100

97101
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getHtmlUrl")

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPerson.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected synchronized void populate() throws IOException {
4141
if (created_at!=null) {
4242
return; // already populated
4343
}
44-
if (root.isOffline()) {
44+
if (root == null || root.isOffline()) {
4545
return; // cannot populate, will have to live with what we have
4646
}
4747
root.retrieve().to(url, this);

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+18-14Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,12 @@ public GHDeploymentBuilder createDeployment(String ref) {
9595
return new GHDeploymentBuilder(this,ref);
9696
}
9797

98-
public PagedIterable<GHDeploymentStatus> getDeploymentStatuses(final int id) {
99-
return new PagedIterable<GHDeploymentStatus>() {
100-
public PagedIterator<GHDeploymentStatus> _iterator(int pageSize) {
101-
return new PagedIterator<GHDeploymentStatus>(root.retrieve().asIterator(getApiTailUrl("deployments")+"/"+id+"/statuses", GHDeploymentStatus[].class, pageSize)) {
102-
@Override
103-
protected void wrapUp(GHDeploymentStatus[] page) {
104-
for (GHDeploymentStatus c : page)
105-
c.wrap(GHRepository.this);
106-
}
107-
};
108-
}
109-
};
98+
/**
99+
* @deprecated
100+
* Use {@code getDeployment(id).listStatuses()}
101+
*/
102+
public PagedIterable<GHDeploymentStatus> getDeploymentStatuses(final int id) throws IOException {
103+
return getDeployment(id).listStatuses();
110104
}
111105

112106
public PagedIterable<GHDeployment> listDeployments(String sha,String ref,String task,String environment){
@@ -123,7 +117,13 @@ protected void wrapUp(GHDeployment[] page) {
123117
};
124118
}
125119
};
120+
}
126121

122+
/**
123+
* Obtains a single {@link GHDeployment} by its ID.
124+
*/
125+
public GHDeployment getDeployment(long id) throws IOException {
126+
return root.retrieve().to("deployments/" + id, GHDeployment.class).wrap(this);
127127
}
128128

129129
private String join(List<String> params, String joinStr) {
@@ -140,8 +140,12 @@ private String getParam(String name, String value) {
140140
return StringUtils.trimToNull(value)== null? null: name+"="+value;
141141
}
142142

143-
public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState) {
144-
return new GHDeploymentStatusBuilder(this,deploymentId,ghDeploymentState);
143+
/**
144+
* @deprecated
145+
* Use {@code getDeployment(deploymentId).createStatus(ghDeploymentState)}
146+
*/
147+
public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState) throws IOException {
148+
return getDeployment(deploymentId).createStatus(ghDeploymentState);
145149
}
146150

147151
private static class GHRepoPermission {

0 commit comments

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