use of com.meisolsson.githubsdk.model.Commit 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.Commit 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.Commit in project PocketHub by pockethub.
the class FullCommitTest method testSingleCommentNoFiles.
/**
* Test commit with no files and one commit comment
*/
public void testSingleCommentNoFiles() {
GitComment comment = GitComment.builder().build();
Commit commit = Commit.builder().build();
FullCommit full = new FullCommit(commit, Collections.singletonList(comment));
assertFalse(full.isEmpty());
assertEquals(comment, full.get(0));
assertTrue(full.getFiles().isEmpty());
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class FullCommitTest method testBothTypesOfComments.
/**
* Test commit with line and global comments
*/
public void testBothTypesOfComments() {
GitHubFile file = GitHubFile.builder().filename("a.txt").build();
GitComment comment1 = GitComment.builder().path(file.filename()).position(10).build();
GitComment comment2 = GitComment.builder().build();
Commit commit = Commit.builder().files(Collections.singletonList(file)).build();
FullCommit full = new FullCommit(commit, new ArrayList<>(Arrays.asList(comment1, comment2)));
assertEquals(1, full.size());
assertEquals(comment2, full.get(0));
assertEquals(1, full.getFiles().size());
assertEquals(comment1, full.getFiles().get(0).get(10).get(0));
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class CommitCompareListFragment method updateList.
private void updateList(CommitCompare compare) {
if (!isUsable()) {
return;
}
this.compare = compare;
ViewUtils.setGone(progress, true);
ViewUtils.setGone(list, false);
LayoutInflater inflater = getActivity().getLayoutInflater();
adapter.clearHeaders();
adapter.getWrappedAdapter().clear();
List<Commit> commits = compare.commits();
if (!commits.isEmpty()) {
View commitHeader = inflater.inflate(R.layout.commit_details_header, null);
((TextView) commitHeader.findViewById(R.id.tv_commit_summary)).setText(MessageFormat.format(getString(R.string.comparing_commits), commits.size()));
adapter.addHeader(commitHeader);
adapter.addHeader(inflater.inflate(R.layout.list_divider, null));
CommitListAdapter commitAdapter = new CommitListAdapter(R.layout.commit_item, inflater, commits, avatars);
for (int i = 0; i < commits.size(); i++) {
Commit commit = commits.get(i);
View view = commitAdapter.getView(i, null, null);
adapter.addHeader(view, commit, true);
adapter.addHeader(inflater.inflate(R.layout.list_divider, null));
}
}
CommitFileListAdapter rootAdapter = adapter.getWrappedAdapter();
rootAdapter.clear();
List<GitHubFile> files = compare.files();
if (files != null && !files.isEmpty()) {
addFileStatHeader(files, inflater);
for (GitHubFile file : files) {
rootAdapter.addItem(file);
}
}
}
Aggregations