Skip to content

Commit a46c7ac

Browse files
committed
Merge branch 'master' of github.com:kohsuke/github-api
2 parents 769d645 + 389330d commit a46c7ac

File tree

4 files changed

+49
-30
lines changed

4 files changed

+49
-30
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<parent>
44
<groupId>org.kohsuke</groupId>
55
<artifactId>pom</artifactId>
6-
<version>3</version>
6+
<version>4</version>
77
</parent>
88

99
<artifactId>github-api</artifactId>
10-
<version>1.35-SNAPSHOT</version>
10+
<version>1.36-SNAPSHOT</version>
1111
<name>GitHub API for Java</name>
1212
<url>http://github-api.kohsuke.org/</url>
1313
<description>GitHub API for Java</description>

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
*/
5656
public class GitHub {
5757
/*package*/ final String login;
58+
59+
5860
/*package*/ final String encodedAuthorization;
5961
/*package*/ final String apiToken;
6062

@@ -65,7 +67,7 @@ public class GitHub {
6567
private final String apiUrl;
6668

6769
private GitHub(String login, String apiToken, String password) {
68-
this ("https://api.github.com", login, apiToken, password);
70+
this (GITHUB_URL, login, apiToken, password);
6971
}
7072

7173
/**
@@ -112,7 +114,11 @@ public static GitHub connect() throws IOException {
112114
} finally {
113115
IOUtils.closeQuietly(in);
114116
}
115-
return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password"));
117+
String oauth = props.getProperty("oauth");
118+
if (oauth!=null)
119+
return new GitHub(GITHUB_URL,oauth);
120+
else
121+
return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password"));
116122
}
117123

118124
/**
@@ -164,7 +170,7 @@ public static GitHub connectAnonymously() {
164170

165171
if (tailApiUrl.startsWith("/")) {
166172
if ("github.com".equals(apiUrl)) {// backward compatibility
167-
return new URL("https://api.github.com" + tailApiUrl);
173+
return new URL(GITHUB_URL + tailApiUrl);
168174
} else {
169175
return new URL(apiUrl + tailApiUrl);
170176
}
@@ -339,4 +345,6 @@ public boolean isCredentialValid() throws IOException {
339345
MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY));
340346
MAPPER.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
341347
}
348+
349+
private static final String GITHUB_URL = "https://api.github.com";
342350
}

src/site/apt/index.apt

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/site/markdown/index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
What is this?
2+
=====
3+
4+
This library defines an object oriented representation of the GitHub API. By "object oriented" we mean
5+
there are classes that correspond to the domain model of GitHub (such as `GHUser` and `GHRepository`),
6+
operations that act on them as defined as methods (such as `GHUser.follow()`), and those object references
7+
are used in favor of using string handle (such as `GHUser.isMemberOf(GHOrganization)` instead of
8+
`GHUser.isMemberOf(String)`)
9+
10+
There are some corners of the GitHub API that's not yet implemented, but
11+
the library is implemented with the right abstractions and libraries to make it very easy to improve the coverage.
12+
13+
Sample Usage
14+
-----
15+
16+
GitHub github = GitHub.connect();
17+
GHRepository repo = github.createRepository(
18+
"new-repository","this is my new repository",
19+
"http://www.kohsuke.org/",true/*public*/);
20+
repo.addCollaborators(github.getUser("abayer"),github.getUser("rtyler"));
21+
repo.delete();
22+
23+
Credential
24+
----
25+
26+
This library allows the caller to supply the credential as parameters, but it also defines a common convention
27+
so that applications using this library will look at the consistent location. In this convention, the library
28+
looks at `~/.github` property file, which should have the following two values:
29+
30+
login=kohsuke
31+
password=012345678
32+
33+
Alternatively, you can have just the OAuth token in this file:
34+
35+
oauth=4d98173f7c075527cb64878561d1fe70
36+

0 commit comments

Comments
 (0)