Skip to content

Commit dac4671

Browse files
committed
Fixed Pull Request
1 parent 2af2775 commit dac4671

File tree

14 files changed

+480
-34
lines changed

14 files changed

+480
-34
lines changed

core/src/main/java/com/github/api/v2/services/CommitService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public interface CommitService extends GitHubService {
3939
*/
4040
public List<Commit> getCommits(String userName, String repositoryName, String branch);
4141

42+
/**
43+
* Gets the commits.
44+
*
45+
* @param userName
46+
* the user name
47+
* @param repositoryName
48+
* the repository name
49+
* @param branch
50+
* the branch
51+
* @param pageNumber
52+
* the page number
53+
*
54+
* @return the commits
55+
*/
56+
public List<Commit> getCommits(String userName, String repositoryName, String branch, int pageNumber);
57+
4258
/**
4359
* Gets the commits.
4460
*

core/src/main/java/com/github/api/v2/services/OrganizationService.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ public interface OrganizationService extends GitHubService {
9494
/**
9595
* Creates the team.
9696
*
97-
* @param team
98-
* the team
97+
* @param organizationName
98+
* the organization name
99+
* @param teamName
100+
* the team name
101+
* @param permission
102+
* the permission
103+
* @param repoNames
104+
* the repo names
105+
*
106+
* @return the team
99107
*/
100108
public Team createTeam(String organizationName, String teamName, Permission permission, List<String> repoNames);
101109

@@ -168,6 +176,8 @@ public interface OrganizationService extends GitHubService {
168176
/**
169177
* Adds the team repository.
170178
*
179+
* @param teamId
180+
* the team id
171181
* @param userName
172182
* the user name
173183
* @param repositoryName

core/src/main/java/com/github/api/v2/services/PullRequestService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public interface PullRequestService extends GitHubService {
8181
* the title
8282
* @param body
8383
* the body
84+
*
85+
* @return the pull request
8486
*/
8587
public PullRequest createPullRequest(String userName, String repositoryName, String base, String head, String title, String body);
8688
}

core/src/main/java/com/github/api/v2/services/RepositoryService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public interface RepositoryService extends GitHubService {
152152
* the home page
153153
* @param visibility
154154
* the visibility
155+
*
156+
* @return the repository
155157
*/
156158
public Repository createRepository(String name, String description, String homePage, Visibility visibility);
157159

core/src/main/java/com/github/api/v2/services/constant/ParameterNames.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,6 @@ public interface ParameterNames {
180180
/** The Constant COLLABORATOR_NAME. */
181181
public static final String COLLABORATOR_NAME = "collaboratorName";
182182

183+
/** The Constant PAGE. */
184+
public static final String PAGE = "page";
183185
}

core/src/main/java/com/github/api/v2/services/impl/BaseGitHubService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.ArrayList;
2424
import java.util.List;
2525

26+
import com.github.api.v2.schema.Discussion;
2627
import com.github.api.v2.schema.Gist;
2728
import com.github.api.v2.schema.Issue;
2829
import com.github.api.v2.schema.Language;
@@ -171,6 +172,13 @@ public Organization.Type deserialize(JsonElement arg0, Type arg1,
171172
return Organization.Type.fromValue(arg0.getAsString());
172173
}
173174
});
175+
builder.registerTypeAdapter(Discussion.Type.class, new JsonDeserializer<Discussion.Type>() {
176+
@Override
177+
public Discussion.Type deserialize(JsonElement arg0, Type arg1,
178+
JsonDeserializationContext arg2) throws JsonParseException {
179+
return Discussion.Type.fromValue(arg0.getAsString());
180+
}
181+
});
174182
builder.registerTypeAdapter(Permission.class, new JsonDeserializer<Permission>() {
175183
@Override
176184
public Permission deserialize(JsonElement arg0, Type arg1,

core/src/main/java/com/github/api/v2/services/impl/CommitServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,17 @@ public Commit getCommit(String userName, String repositoryName, String sha) {
5151
@Override
5252
public List<Commit> getCommits(String userName, String repositoryName,
5353
String branch) {
54+
return getCommits(userName, repositoryName, branch, 1);
55+
}
56+
57+
/* (non-Javadoc)
58+
* @see com.github.api.v2.services.CommitService#getCommits(java.lang.String, java.lang.String, java.lang.String, int)
59+
*/
60+
@Override
61+
public List<Commit> getCommits(String userName, String repositoryName,
62+
String branch, int pageNumber) {
5463
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.CommitApiUrls.GET_COMMITS_URL);
55-
String apiUrl = builder.withField(ParameterNames.USER_NAME, userName).withField(ParameterNames.REPOSITORY_NAME, repositoryName).withField(ParameterNames.BRANCH, branch).buildUrl();
64+
String apiUrl = builder.withField(ParameterNames.USER_NAME, userName).withField(ParameterNames.REPOSITORY_NAME, repositoryName).withField(ParameterNames.BRANCH, branch).withParameter(ParameterNames.PAGE, String.valueOf(pageNumber)).buildUrl();
5665
JsonObject json = unmarshall(callApiGet(apiUrl));
5766

5867
return unmarshall(new TypeToken<List<Commit>>(){}, json.get("commits"));

core/src/main/java/com/github/api/v2/services/impl/PullRequestServiceImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.github.api.v2.services.constant.GitHubApiUrls;
2727
import com.github.api.v2.services.constant.ParameterNames;
2828
import com.github.api.v2.services.constant.GitHubApiUrls.GitHubApiUrlBuilder;
29-
import com.google.gson.GsonBuilder;
3029
import com.google.gson.JsonObject;
3130
import com.google.gson.reflect.TypeToken;
3231

@@ -87,13 +86,4 @@ public PullRequest createPullRequest(String userName, String repositoryName, Str
8786

8887
return unmarshall(new TypeToken<PullRequest>(){}, json.get("pull"));
8988
}
90-
91-
/* (non-Javadoc)
92-
* @see com.github.api.v2.services.impl.BaseGitHubService#getGsonBuilder()
93-
*/
94-
protected GsonBuilder getGsonBuilder() {
95-
GsonBuilder gson = super.getGsonBuilder();
96-
gson.setDateFormat("yyyy-MM-dd'T'HH:mm:ss");
97-
return gson;
98-
}
9989
}

core/src/main/resources/com/github/api/v2/services/constant/GitHubApiUrls.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ com.github.api.v2.services.repositoryService.getBranches=http://github.com/api/{
7676
com.github.api.v2.services.repositoryService.getRepositoryArchive=https://github.com/{userName}/{repositoryName}/zipball/{branch}
7777

7878
# Commit API
79-
com.github.api.v2.services.commitService.getCommits=http://github.com/api/{version}/{format}/commits/list/{userName}/{repositoryName}/{branch}
79+
com.github.api.v2.services.commitService.getCommits=http://github.com/api/{version}/{format}/commits/list/{userName}/{repositoryName}/{branch}?{page}
8080
com.github.api.v2.services.commitService.getCommitsFile=http://github.com/api/{version}/{format}/commits/list/{userName}/{repositoryName}/{branch}/{filePath}
8181
com.github.api.v2.services.commitService.getCommit=http://github.com/api/{version}/{format}/commits/show/{userName}/{repositoryName}/{sha}
8282

core/src/test/java/com/github/api/v2/services/constant/TestConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,16 @@ public final class TestConstants {
145145

146146
/** The Constant TEST_HEAD_SHA. */
147147
public static final String TEST_HEAD_SHA = testConstants.getProperty("com.github.api.v2.services.testHeadSha");
148+
149+
/** The Constant TEST_ORGANIZATION_NAME. */
150+
public static final String TEST_ORGANIZATION_NAME = testConstants.getProperty("com.github.api.v2.services.testOrgName");
151+
152+
/** The Constant TEST_TEAM_NAME. */
153+
public static final String TEST_TEAM_NAME = testConstants.getProperty("com.github.api.v2.services.testTeamName");
148154

155+
/** The Constant TEST_PULL_REQUEST_NUMBER. */
156+
public static final String TEST_PULL_REQUEST_NUMBER = testConstants.getProperty("com.github.api.v2.services.testPullRequestNumber");
157+
149158
/**
150159
* Instantiates a new test constants.
151160
*/

0 commit comments

Comments
 (0)