Search in sources :

Example 1 with Commit

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));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitUser(com.meisolsson.githubsdk.model.git.GitUser)

Example 2 with 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));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) Date(java.util.Date) GitUser(com.meisolsson.githubsdk.model.git.GitUser)

Example 3 with 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());
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 4 with Commit

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));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 5 with Commit

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);
        }
    }
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) LayoutInflater(android.view.LayoutInflater) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

Commit (com.meisolsson.githubsdk.model.Commit)16 GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)7 FullCommit (com.github.pockethub.android.core.commit.FullCommit)6 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)5 GitComment (com.meisolsson.githubsdk.model.git.GitComment)5 GitUser (com.meisolsson.githubsdk.model.git.GitUser)4 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 Date (java.util.Date)2 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 StyledText (com.github.pockethub.android.ui.StyledText)1 RepositoryCommentService (com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)1 IOException (java.io.IOException)1