use of com.meisolsson.githubsdk.model.git.GitUser in project PocketHub by pockethub.
the class CommitUtilsTest method testGetCommitter.
/**
* Test parsing committer from commit
*/
public void testGetCommitter() {
Commit commit = Commit.builder().build();
assertNull(CommitUtils.getCommitter(commit));
GitCommit rawCommit = GitCommit.builder().build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getCommitter(commit));
GitUser user = GitUser.builder().build();
rawCommit = rawCommit.toBuilder().committer(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getCommitter(commit));
user = user.toBuilder().name("u1").build();
rawCommit = rawCommit.toBuilder().committer(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertEquals("u1", CommitUtils.getCommitter(commit));
user = user.toBuilder().name("u2").build();
rawCommit = rawCommit.toBuilder().committer(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertEquals("u2", CommitUtils.getCommitter(commit));
}
use of com.meisolsson.githubsdk.model.git.GitUser in project PocketHub by pockethub.
the class CommitUtilsTest method testGetCommitterDate.
/**
* Test parsing committer date from commit
*/
public void testGetCommitterDate() {
Commit commit = Commit.builder().build();
assertNull(CommitUtils.getCommitterDate(commit));
GitCommit rawCommit = GitCommit.builder().build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getCommitterDate(commit));
GitUser user = GitUser.builder().build();
rawCommit = rawCommit.toBuilder().committer(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getCommitterDate(commit));
user = user.toBuilder().date(new Date(12000)).build();
rawCommit = rawCommit.toBuilder().committer(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertEquals(new Date(12000), CommitUtils.getCommitterDate(commit));
}
use of com.meisolsson.githubsdk.model.git.GitUser in project PocketHub by pockethub.
the class CommitUtils method getCommitterDate.
/**
* Get committer date of commit
*
* @param commit
* @return author name or null if missing
*/
public static Date getCommitterDate(final Commit commit) {
GitCommit rawCommit = commit.commit();
if (rawCommit == null) {
return null;
}
GitUser commitCommitter = rawCommit.committer();
return commitCommitter != null && commitCommitter.date() != null ? commitCommitter.date() : null;
}
use of com.meisolsson.githubsdk.model.git.GitUser in project PocketHub by pockethub.
the class CommitUtils method getCommitter.
/**
* Get committer of commit
* <p>
* This checks both the {@link Commit} and the underlying
* {@link Commit} to retrieve a name
*
* @param commit
* @return committer name or null if missing
*/
public static String getCommitter(final Commit commit) {
User committer = commit.committer();
if (committer != null) {
return committer.login();
}
GitCommit rawCommit = commit.commit();
if (rawCommit == null) {
return null;
}
GitUser commitCommitter = rawCommit.committer();
return commitCommitter != null ? commitCommitter.name() : null;
}
use of com.meisolsson.githubsdk.model.git.GitUser in project PocketHub by pockethub.
the class CommitUtils method getAuthorDate.
/**
* Get author date of commit
*
* @param commit
* @return author name or null if missing
*/
public static Date getAuthorDate(final Commit commit) {
GitCommit rawCommit = commit.commit();
if (rawCommit == null) {
return null;
}
GitUser commitAuthor = rawCommit.author();
return commitAuthor != null && commitAuthor.date() != null ? commitAuthor.date() : null;
}