Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit's short info model #42

Merged
merged 3 commits into from
Sep 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,79 @@
*/
public class GHCommit {
private GHRepository owner;

private GHCommitShortInfo commit;

public static class GHCommitShortInfo {
private GHAuthor author;

private GHAuthor committer;

private String message;

private int comment_count;

public GHAuthor getAuthor() {
return author;
}

public void setAuthor(GHAuthor author) {
this.author = author;
}

public GHAuthor getCommitter() {
return committer;
}

public void setCommitter(GHAuthor committer) {
this.committer = committer;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public int getComment_count() {
return comment_count;
}

public void setComment_count(int comment_count) {
this.comment_count = comment_count;
}
}

public static class GHAuthor {
private String name,email,date;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

}

public static class Stats {
int total,additions,deletions;
Expand Down Expand Up @@ -110,8 +183,18 @@ static class User {
Stats stats;
List<Parent> parents;
User author,committer;



/**
public GHCommitShortInfo getCommitShortInfo() {
return commit;
}

public void setCommit(GHCommitShortInfo commit) {
this.commit = commit;
}

/**
* The repository that contains the commit.
*/
public GHRepository getOwner() {
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/kohsuke/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ public void testCommitStatus() throws Exception {
assertEquals("oops!",state.getDescription());
assertEquals("http://jenkins-ci.org/",state.getTargetUrl());
}

public void testCommitShortInfo() throws Exception {
GHCommit commit = gitHub.getUser("kohsuke").getRepository("test").getCommit("c77360d6f2ff2c2e6dd11828ad5dccf72419fa1b");
assertEquals(commit.getCommitShortInfo().getAuthor().getName(), "Kohsuke Kawaguchi");
assertEquals(commit.getCommitShortInfo().getMessage(), "Added a file");
}

public void testPullRequestPopulate() throws Exception {
GHRepository r = gitHub.getUser("kohsuke").getRepository("github-api");
Expand Down