From 45286598aaf739347844bedacdaa33baaf0af703 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Jan 2013 16:43:43 -0800 Subject: [PATCH 1/4] adding OAuth support in ~/.github --- src/main/java/org/kohsuke/github/GitHub.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index e885b89f8..a24fac3f5 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -55,6 +55,8 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.*; */ public class GitHub { /*package*/ final String login; + + /*package*/ final String encodedAuthorization; /*package*/ final String apiToken; @@ -65,7 +67,7 @@ public class GitHub { private final String apiUrl; private GitHub(String login, String apiToken, String password) { - this ("https://api.github.com", login, apiToken, password); + this (GITHUB_URL, login, apiToken, password); } /** @@ -112,7 +114,11 @@ public class GitHub { } finally { IOUtils.closeQuietly(in); } - return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password")); + String oauth = props.getProperty("oauth"); + if (oauth!=null) + return new GitHub(GITHUB_URL,oauth); + else + return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password")); } /** @@ -164,7 +170,7 @@ public class GitHub { if (tailApiUrl.startsWith("/")) { if ("github.com".equals(apiUrl)) {// backward compatibility - return new URL("https://api.github.com" + tailApiUrl); + return new URL(GITHUB_URL + tailApiUrl); } else { return new URL(apiUrl + tailApiUrl); } @@ -339,4 +345,6 @@ public class GitHub { MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY)); MAPPER.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); } + + private static final String GITHUB_URL = "https://api.github.com"; } From 887ca772e0a7e82704255ccf51f0696dafbf800f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Jan 2013 16:45:17 -0800 Subject: [PATCH 2/4] switching to Markdown --- pom.xml | 2 +- src/site/apt/index.apt | 25 ------------------------- src/site/markdown/index.md | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 26 deletions(-) delete mode 100644 src/site/apt/index.apt create mode 100644 src/site/markdown/index.md diff --git a/pom.xml b/pom.xml index b9125ef22..5f6973bb5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.kohsuke pom - 3 + 4 github-api diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt deleted file mode 100644 index 28254de23..000000000 --- a/src/site/apt/index.apt +++ /dev/null @@ -1,25 +0,0 @@ -What is this? - - This library defines an object oriented representation of the GitHub API. The library doesn't yet cover the entirety of the GitHub API, but it's implemented with the right abstractions and libraries to make it very easy to improve the coverage. - -Sample Usage - ------------------- -GitHub github = GitHub.connect(); -GHRepository repo = github.createRepository( - "new-repository","this is my new repository", - "http://www.kohsuke.org/",true/*public*/); -repo.addCollaborators(github.getUser("abayer"),github.getUser("rtyler")); -repo.delete(); ------------------- - -Credential - - This library allows the caller to supply the credential as parameters, but it also defines a common convention - so that applications using this library will look at the consistent location. In this convention, the library - looks at "~/.github" property file, which should have the following two values: - ------------------- -login=kohsuke -token=012345678 ------------------- diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md new file mode 100644 index 000000000..ba9fbb528 --- /dev/null +++ b/src/site/markdown/index.md @@ -0,0 +1,36 @@ +What is this? +===== + +This library defines an object oriented representation of the GitHub API. By "object oriented" we mean +there are classes that correspond to the domain model of GitHub (such as `GHUser` and `GHRepository`), +operations that act on them as defined as methods (such as `GHUser.follow()`), and those object references +are used in favor of using string handle (such as `GHUser.isMemberOf(GHOrganization)` instead of +`GHUser.isMemberOf(String)`) + +There are some corners of the GitHub API that's not yet implemented, but +the library is implemented with the right abstractions and libraries to make it very easy to improve the coverage. + +Sample Usage +----- + + GitHub github = GitHub.connect(); + GHRepository repo = github.createRepository( + "new-repository","this is my new repository", + "http://www.kohsuke.org/",true/*public*/); + repo.addCollaborators(github.getUser("abayer"),github.getUser("rtyler")); + repo.delete(); + +Credential +---- + +This library allows the caller to supply the credential as parameters, but it also defines a common convention +so that applications using this library will look at the consistent location. In this convention, the library +looks at `~/.github` property file, which should have the following two values: + + login=kohsuke + password=012345678 + +Alternatively, you can have just the OAuth token in this file: + + oauth=4d98173f7c075527cb64878561d1fe70 + From 9d75913005100d181bca2b1cb5c6e9620850409f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Jan 2013 16:47:24 -0800 Subject: [PATCH 3/4] [maven-release-plugin] prepare release github-api-1.35 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f6973bb5..41e1a14fb 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.35-SNAPSHOT + 1.35 GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java From 389330df2e3637d0e7b2a57c5e0b72253ea2e74d Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 6 Jan 2013 16:47:29 -0800 Subject: [PATCH 4/4] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41e1a14fb..6aa7f12fc 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.35 + 1.36-SNAPSHOT GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java