Skip to content

Commit

Permalink
ISSUE-260: Add committer & committerTimestamp to Commit object
Browse files Browse the repository at this point in the history
  • Loading branch information
tjxn committed Jan 30, 2021
1 parent 3e2c62b commit 1a64847
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
37 changes: 23 additions & 14 deletions src/main/java/com/cdancy/bitbucket/rest/domain/commit/Commit.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public abstract class Commit implements ErrorsHolder {

public abstract long authorTimestamp();

@Nullable
public abstract Author committer();

public abstract long committerTimestamp();

@Nullable
public abstract String message();

Expand All @@ -49,22 +54,26 @@ public abstract class Commit implements ErrorsHolder {
Commit() {
}

@SerializedNames({ "id", "displayId", "author",
"authorTimestamp", "message", "parents", "errors" })
public static Commit create(final String id,
final String displayId,
@SerializedNames({ "id", "displayId", "author",
"authorTimestamp", "committer", "committerTimestamp", "message", "parents", "errors" })
public static Commit create(final String id,
final String displayId,
final Author author,
final long authorTimestamp,
final String message,
final List<Parents> parents,
final long authorTimestamp,
final Author committer,
final long committerTimestamp,
final String message,
final List<Parents> parents,
final List<Error> errors) {

return new AutoValue_Commit(BitbucketUtils.nullToEmpty(errors),
id,
displayId,
author,
authorTimestamp,
message,

return new AutoValue_Commit(BitbucketUtils.nullToEmpty(errors),
id,
displayId,
author,
authorTimestamp,
committer,
committerTimestamp,
message,
BitbucketUtils.nullToEmpty(parents));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public static CommitPage createCommitPageFromErrors(final List<Error> errors) {
}

public static Commit createCommitFromErrors(final List<Error> errors) {
return Commit.create("-1", "-1", null, 0, null, null, errors);
return Commit.create("-1", "-1", null, 0, null, 0, null, null, errors);
}

public static Tag createTagFromErrors(final List<Error> errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CommitsApiMockTest extends BaseBitbucketMockTest {
private final String getMethod = "GET";
private final String restApiPath = "/rest/api/";
private final String limitKeyword = "limit";

public void testGetCommit() throws Exception {
final MockWebServer server = mockWebServer();

Expand All @@ -56,6 +56,10 @@ public void testGetCommit() throws Exception {
assertThat(commit).isNotNull();
assertThat(commit.errors().isEmpty()).isTrue();
assertThat(commit.id().equalsIgnoreCase(commitHash)).isTrue();
assertThat(commit.authorTimestamp()).isNotNull().isNotEqualTo(0);
assertThat(commit.author()).isNotNull();
assertThat(commit.committerTimestamp()).isNotNull().isNotEqualTo(0);
assertThat(commit.committer()).isNotNull();

assertSent(server, getMethod, restBasePath + BitbucketApiMetadata.API_VERSION
+ "/projects/" + projectKey + "/repos/" + repoKey + "/commits/" + commitHash);
Expand Down Expand Up @@ -121,7 +125,7 @@ public void testGetPullRequestChangesOnError() throws Exception {
server.shutdown();
}
}

public void testListCommits() throws Exception {
final MockWebServer server = mockWebServer();

Expand Down
9 changes: 8 additions & 1 deletion src/test/resources/commit.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
"displayId": "abcdef0123a",
"author": {
"name": "charlie",
"emailAddress": "[email protected]"
"emailAddress": "[email protected]",
"displayName": "Charlie Brown"
},
"authorTimestamp": 1484800877151,
"message": "WIP on feature 1",
"committer": {
"name": "john",
"emailAddress": "[email protected]",
"displayName": "John Smith"
},
"committerTimestamp": 1594900977151,
"parents": [
{
"id": "abcdef0123abcdef4567abcdef8987abcdef6543",
Expand Down

0 comments on commit 1a64847

Please sign in to comment.