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 2eb8ce6

Browse filesBrowse files
Merge branch 'master' into issue_546_list_repository_topics
2 parents a5b6302 + 739551c commit 2eb8ce6
Copy full SHA for 2eb8ce6

File tree

Expand file treeCollapse file tree

38 files changed

+1956
-60
lines changed
Filter options
Expand file treeCollapse file tree

38 files changed

+1956
-60
lines changed

‎.github/release-drafter.yml

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name-template: 'v$NEXT_PATCH_VERSION 🌈'
2+
tag-template: 'v$NEXT_PATCH_VERSION'
3+
categories:
4+
- title: '🚀 Features'
5+
labels:
6+
- 'feature'
7+
- 'enhancement'
8+
- title: '🐛 Bug Fixes'
9+
labels:
10+
- 'fix'
11+
- 'bugfix'
12+
- 'bug'
13+
- title: '🧰 Maintenance'
14+
label: 'chore'
15+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
16+
template: |
17+
## Changes
18+
19+
$CHANGES

‎CODE_OF_CONDUCT.md

Copy file name to clipboard
+76Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at bitwiseman@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
<description>GitHub API for Java</description>
1515

1616
<scm>
17-
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
18-
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
17+
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
18+
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
1919
<url>https://${project.artifactId}.kohsuke.org/</url>
2020
<tag>HEAD</tag>
2121
</scm>
2222

2323
<distributionManagement>
2424
<site>
2525
<id>github-pages</id>
26-
<url>gitsite:git@github.com/kohsuke/${project.artifactId}.git</url>
26+
<url>gitsite:git@github.com/github-api/${project.artifactId}.git</url>
2727
</site>
2828
</distributionManagement>
2929

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class GHAppCreateTokenBuilder {
3535
*
3636
*/
3737
@Preview @Deprecated
38-
public GHAppCreateTokenBuilder repositoryIds(List<Integer> repositoryIds) {
38+
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
3939
this.builder.with("repository_ids",repositoryIds);
4040
return this;
4141
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHMilestone.java
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,29 @@ public void reopen() throws IOException {
8585
edit("state", "open");
8686
}
8787

88+
/**
89+
* Deletes this milestone.
90+
*/
91+
public void delete() throws IOException {
92+
root.retrieve().method("DELETE").to(getApiRoute());
93+
}
94+
8895
private void edit(String key, Object value) throws IOException {
8996
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
9097
}
9198

99+
public void setTitle(String title) throws IOException {
100+
edit("title", title);
101+
}
102+
103+
public void setDescription(String description) throws IOException {
104+
edit("description", description);
105+
}
106+
107+
public void setDueOn(Date dueOn) throws IOException {
108+
edit("due_on", GitHub.printDate(dueOn));
109+
}
110+
92111
protected String getApiRoute() {
93112
return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/milestones/"+number;
94113
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public PagedIterable<GHDeployment> listDeployments(String sha,String ref,String
129129
* Obtains a single {@link GHDeployment} by its ID.
130130
*/
131131
public GHDeployment getDeployment(long id) throws IOException {
132-
return root.retrieve().to("deployments/" + id, GHDeployment.class).wrap(this);
132+
return root.retrieve().to(getApiTailUrl("deployments/" + id), GHDeployment.class).wrap(this);
133133
}
134134

135135
private String join(List<String> params, String joinStr) {

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHub.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,9 @@ public Reader renderMarkdown(String text) throws IOException {
956956
}
957957

958958
/*package*/ static String printDate(Date dt) {
959-
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(dt);
959+
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
960+
df.setTimeZone(TimeZone.getTimeZone("GMT"));
961+
return df.format(dt);
960962
}
961963

962964
/*package*/ static final ObjectMapper MAPPER = new ObjectMapper();

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHubBuilder.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ public GitHubBuilder withOAuthToken(String oauthToken, String user) {
180180
this.user = user;
181181
return this;
182182
}
183+
184+
/**
185+
* Configures {@link GitHubBuilder} with Installation Token generated by the GitHub Application
186+
*
187+
* @param appInstallationToken A string containing the GitHub App installation token
188+
* @return the configured Builder from given GitHub App installation token.
189+
* @see GHAppInstallation#createToken(java.util.Map)
190+
*/
191+
public GitHubBuilder withAppInstallationToken(String appInstallationToken){
192+
return withOAuthToken(appInstallationToken, "");
193+
}
194+
183195
public GitHubBuilder withJwtToken(String jwtToken){
184196
this.jwtToken = jwtToken;
185197
return this;

‎src/site/apt/index.apt

Copy file name to clipboard
+154Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
What is this?
2+
3+
This library defines an object oriented representation of the GitHub API. By "object oriented" we mean
4+
there are classes that correspond to the domain model of GitHub (such as <<<GHUser>>> and <<<GHRepository>>>),
5+
operations that act on them as defined as methods (such as <<<GHUser.follow()>>>), and those object references
6+
are used in favor of using string handle (such as <<<GHUser.isMemberOf(GHOrganization)>>> instead of
7+
<<<GHUser.isMemberOf(String)>>>)
8+
9+
The library supports both github.com and GitHub Enterprise.
10+
11+
Most of the GitHub APIs are covered, although there are some corners that are still not yet implemented.
12+
13+
Sample Usage
14+
15+
+-----+
16+
GitHub github = GitHub.connect();
17+
18+
GHRepository repo = github.createRepository(
19+
"new-repository","this is my new repository",
20+
"http://www.kohsuke.org/",true/*public*/);
21+
repo.addCollaborators(github.getUser("abayer"),github.getUser("rtyler"));
22+
repo.delete();
23+
+-----+
24+
25+
Authentication
26+
27+
The library allows connecting to GitHub via several different authentication mechanisms.
28+
29+
* Programmatically
30+
31+
To connect via Username and Password (not recommended):
32+
33+
+-----+
34+
GitHub github = new GitHubBuilder().withPassword("my_user", "my_passwd").build();
35+
+-----+
36+
37+
To connect via Personal access token:
38+
39+
+-----+
40+
// If you don't specify the GitHub user id then the sdk will retrieve it via /user endpoint
41+
GitHub github = new GitHubBuilder().withOAuthToken("my_personal_token").build();
42+
43+
// If the token has access to an organization, you can specify it here.
44+
GitHub github = new GitHubBuilder().withOAuthToken("my_personal_token","user_id_OR_org_name").build();
45+
+-----+
46+
47+
To connect via JWT token as a GitHub App:
48+
49+
+-----+
50+
GitHub github = new GitHubBuilder().withJwtToken("my_jwt_token").build();
51+
+-----+
52+
53+
To connect via GitHub App installation token on behalf of a user or organization:
54+
55+
+-----+
56+
GitHub github = new GitHubBuilder().withAppInstallationToken("my_installation_token").build();
57+
+-----+
58+
59+
* Property file
60+
61+
This library defines a common convention so that applications using this library will look at a consistent location.
62+
In this convention, the library looks at <<<~/.github>>> property file. The content of the files depends on the way
63+
you want this library to authenticate as shown below:
64+
65+
66+
To connect via Username and Password (not recommended):
67+
68+
+-----+
69+
login=kohsuke
70+
password=012345678
71+
+-----+
72+
73+
To connect via Personal access token:
74+
75+
+-----+
76+
oauth=4d98173f7c075527cb64878561d1fe70
77+
+-----+
78+
79+
To connect via Personal access token as a user or organization:
80+
81+
+-----+
82+
login=my_org
83+
oauth=4d98173f7c075527cb64878561d1fe70
84+
+-----+
85+
86+
To connect via JWT token as a GitHub App:
87+
88+
+-----+
89+
jwt=my_jwt_token
90+
+-----+
91+
92+
Once your <<<~/.github>>> property file is properly configured, you can obtain a <<<GitHub>>> instance using:
93+
94+
+-----+
95+
// if you are using the default configuration file
96+
GitHub github = new GitHubBuilder().fromPropertyFile().build();
97+
98+
// if you need to use a separate configuration file
99+
GitHub github = new GitHubBuilder().fromPropertyFile("location/my_custom_github.properties").build();
100+
+-----+
101+
102+
* Environmental variables
103+
104+
This library also allows developers to authenticate GitHub with environmental variables.
105+
106+
To connect via Username and Password (not recommended):
107+
108+
+-----+
109+
export GITHUB_LOGIN=kohsuke
110+
export GITHUB_PASSWORD=012345678
111+
+-----+
112+
113+
To connect via Personal access token:
114+
115+
+-----+
116+
export GITHUB_OAUTH=4d98173f7c075527cb64878561d1fe70
117+
+-----+
118+
119+
To connect via Personal access token as a user or organization:
120+
121+
+-----+
122+
export GITHUB_LOGIN=my_org
123+
export GITHUB_OAUTH=4d98173f7c075527cb64878561d1fe70
124+
+-----+
125+
126+
To connect via JWT token as a GitHub App:
127+
128+
+-----+
129+
export GITHUB_JWT=my_jwt_token
130+
+-----+
131+
132+
Once exported, you can obtain a <<<GitHub>>> instance using:
133+
134+
+-----+
135+
GitHub github = new GitHubBuilder().fromEnvironment().build();
136+
+-----+
137+
138+
139+
Pluggable HTTP client
140+
141+
This library comes with a pluggable connector to use different HTTP client implementations
142+
through <<<HttpConnector>>>. In particular, this means you can use {{{http://square.github.io/okhttp/}OkHttp}},
143+
so we can make use of it's HTTP response cache.
144+
Making a conditional request against the GitHub API and receiving a 304 response
145+
{{{http://developer.github.com/v3/#conditional-requests}does not count against the rate limit}}.
146+
147+
The following code shows an example of how to set up persistent cache on the disk:
148+
149+
+-----+
150+
Cache cache = new Cache(cacheDirectory, 10 * 1024 * 1024); // 10MB cache
151+
GitHub gitHub = GitHubBuilder.fromCredentials()
152+
.withConnector(new OkHttpConnector(new OkUrlFactory(new OkHttpClient().setCache(cache))))
153+
.build();
154+
+-----+

0 commit comments

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