use of com.meisolsson.githubsdk.model.git.GitCommit in project PocketHub by pockethub.
the class CommitUtilsTest method testAbbreviate.
/**
* Test commit SHA-1 abbreviation
*/
public void testAbbreviate() {
assertNull(CommitUtils.abbreviate((GitCommit) null));
assertNull(CommitUtils.abbreviate((Commit) null));
assertNull(CommitUtils.abbreviate((String) null));
assertEquals("", CommitUtils.abbreviate(""));
assertEquals("a", CommitUtils.abbreviate("a"));
assertEquals("abcdefghij", CommitUtils.abbreviate("abcdefghijk"));
GitCommit gitCommit = GitCommit.builder().sha("abc").build();
assertEquals("abc", CommitUtils.abbreviate(gitCommit));
Commit commit = Commit.builder().sha("abcd").build();
assertEquals("abcd", CommitUtils.abbreviate(commit));
}
use of com.meisolsson.githubsdk.model.git.GitCommit in project PocketHub by pockethub.
the class CommitUtilsTest method testGetAuthorDate.
/**
* Test parsing author date from commit
*/
public void testGetAuthorDate() {
Commit commit = Commit.builder().build();
assertNull(CommitUtils.getAuthorDate(commit));
GitCommit rawCommit = GitCommit.builder().build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getAuthorDate(commit));
GitUser user = GitUser.builder().build();
rawCommit = rawCommit.toBuilder().author(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getAuthorDate(commit));
user = user.toBuilder().date(new Date(12000)).build();
rawCommit = rawCommit.toBuilder().author(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertEquals(new Date(12000), CommitUtils.getAuthorDate(commit));
}
use of com.meisolsson.githubsdk.model.git.GitCommit in project PocketHub by pockethub.
the class CommitUtilsTest method testGetAuthor.
/**
* Test parsing author from commit
*/
public void testGetAuthor() {
Commit commit = Commit.builder().build();
assertNull(CommitUtils.getAuthor(commit));
GitCommit rawCommit = GitCommit.builder().build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getAuthor(commit));
GitUser user = GitUser.builder().build();
rawCommit = rawCommit.toBuilder().author(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertNull(CommitUtils.getAuthor(commit));
user = user.toBuilder().name("u1").build();
rawCommit = rawCommit.toBuilder().author(user).build();
commit = commit.toBuilder().commit(rawCommit).build();
assertEquals("u1", CommitUtils.getAuthor(commit));
}
use of com.meisolsson.githubsdk.model.git.GitCommit in project PocketHub by pockethub.
the class NewsFragment method openPush.
private void openPush(GitHubEvent event) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
if (repo == null) {
return;
}
PushPayload payload = ((PushPayload) event.payload());
List<GitCommit> commits = payload.commits();
if (commits == null || commits.isEmpty()) {
return;
}
if (commits.size() > 1) {
String base = payload.before();
String head = payload.head();
if (!TextUtils.isEmpty(base) && !TextUtils.isEmpty(head)) {
startActivity(CommitCompareViewActivity.createIntent(repo, base, head));
}
} else {
GitCommit commit = commits.get(0);
String sha = commit != null ? commit.sha() : null;
if (!TextUtils.isEmpty(sha)) {
startActivity(CommitViewActivity.createIntent(repo, sha));
}
}
}
Aggregations