Search in sources :

Example 31 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class IssueStoreTest method testReuseIssue.

/**
 * Verify issue is updated when re-added
 */
@Test
public void testReuseIssue() {
    IssueStore store = new IssueStore();
    Repository repo = InfoUtils.createRepoFromData("owner", "name");
    assertNull(store.getIssue(repo, 1));
    Issue issue = Issue.builder().repository(repo).number(1).body("body").build();
    assertEquals(issue, store.addIssue(issue));
    assertEquals(issue, store.getIssue(repo, 1));
    Issue issue2 = Issue.builder().repository(repo).number(1).body("body2").build();
    assertNotEquals(issue, store.addIssue(issue2));
    assertNotEquals(issue2.body(), issue.body());
    assertNotEquals(issue, store.getIssue(repo, 1));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Issue(com.meisolsson.githubsdk.model.Issue) IssueStore(com.github.pockethub.android.core.issue.IssueStore) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 32 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class RepositoryUriMatcherTest method testHttpUriWithOwnerAndName.

/**
 * Verify URI with owner but no name
 */
@Test
public void testHttpUriWithOwnerAndName() {
    Repository repo = RepositoryUriMatcher.getRepository(Uri.parse("http://github.com/defunkt/resque"));
    assertNotNull(repo);
    assertEquals("resque", repo.name());
    assertNotNull(repo.owner());
    assertEquals("defunkt", repo.owner().login());
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Test(org.junit.Test)

Example 33 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class AccountDataManager method getIssueFilters.

/**
 * Get bookmarked issue filters
 * <p/>
 * This method may perform network I/O and should never be called on the
 * UI-thread
 *
 * @return non-null but possibly empty collection of issue filters
 */
public List<IssueFilter> getIssueFilters() {
    List<GetFilters> filters = dbCache.database.getIssue_filterQueries().getFilters().executeAsList();
    List<IssueFilter> issueFilters = new ArrayList<>();
    for (GetFilters f : filters) {
        Users owner = dbCache.database.getOrganizationsQueries().selectUser(f.getOwnerId()).executeAsOne();
        Repository.Builder builder = Repository.builder().id(f.getRepoId()).name(f.getName()).owner(User.builder().id(owner.getId()).login(owner.getLogin()).name(owner.getName()).avatarUrl(owner.getAvatarurl()).build()).isPrivate(f.getPrivate()).isFork(f.getFork()).description(f.getDescription()).forksCount(f.getForks()).watchersCount(f.getWatchers()).language(f.getLanguage()).hasIssues(f.getHasIssues()).mirrorUrl(f.getMirrorUrl()).permissions(Permissions.builder().admin(f.getPermissions_admin()).pull(f.getPermissions_pull()).push(f.getPermissions_push()).build());
        if (f.getOrgId() != null) {
            Users org = dbCache.database.getOrganizationsQueries().selectUser(f.getOrgId()).executeAsOne();
            builder.organization(User.builder().id(org.getId()).login(org.getLogin()).name(org.getName()).avatarUrl(org.getAvatarurl()).build());
        }
        Repository repo = builder.build();
        IssueFilter filter = new IssueFilter(repo, f.getId());
        if (f.getLogin() != null) {
            filter.setAssignee(User.builder().id(f.getId__()).name(f.getName_()).login(f.getLogin()).avatarUrl(f.getAvatarurl()).build());
        }
        if (f.getMilestone_id() != null) {
            filter.setMilestone(Milestone.builder().id(f.getMilestone_id()).build());
        }
        filter.setDirection(f.getDirection());
        filter.setOpen(f.getOpen());
        filter.setSortType(f.getSort_type());
        List<GetFilterLabels> filterLabels = dbCache.database.getIssue_filterQueries().getFilterLabels(filter.getId()).executeAsList();
        for (GetFilterLabels filterLabel : filterLabels) {
            filter.addLabel(Label.builder().name(filterLabel.getName()).color(filterLabel.getColor()).build());
        }
        issueFilters.add(filter);
    }
    return issueFilters;
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) GetFilterLabels(com.github.pockethub.android.GetFilterLabels) ArrayList(java.util.ArrayList) GetFilters(com.github.pockethub.android.GetFilters) Users(com.github.pockethub.android.Users) IssueFilter(com.github.pockethub.android.core.issue.IssueFilter)

Example 34 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class AccountDataManager method addIssueFilter.

/**
 * Add issue filter to store
 * <p/>
 * This method may perform file I/O and should never be called on the
 * UI-thread
 *
 * @param filter
 */
public Single<IssueFilter> addIssueFilter(final IssueFilter filter) {
    Repository repo = filter.getRepository();
    dbCache.getDatabase().getRepositoriesQueries().replaceRepo(repo.id(), repo.name(), repo.organization() != null ? repo.organization().id() : null, repo.owner().id(), repo.isPrivate(), repo.isFork(), repo.description(), repo.forksCount(), repo.watchersCount(), repo.language(), repo.hasIssues(), repo.mirrorUrl(), repo.permissions().admin(), repo.permissions().pull(), repo.permissions().push());
    for (Label label : filter.getLabels()) {
        dbCache.database.getIssue_filterQueries().insertOrReplaceLabel(repo.id(), label.name(), label.color());
        dbCache.database.getIssue_filterQueries().insertOrReplaceIssueFilterLabel(filter.getId(), repo.id(), label.name());
    }
    if (filter.getMilestone() != null) {
        dbCache.database.getIssue_filterQueries().insertOrReplaceMilestone(repo.id(), filter.getMilestone().title(), filter.getMilestone().state(), filter.getMilestone().id(), filter.getMilestone().number().longValue());
    }
    if (filter.getAssignee() != null) {
        dbCache.database.getOrganizationsQueries().replaceUser(filter.getAssignee().id(), filter.getAssignee().login(), filter.getAssignee().name(), filter.getAssignee().avatarUrl());
    }
    dbCache.database.getIssue_filterQueries().insertOrReplaceIssueFilter(filter.getId(), repo.id(), filter.getMilestone() != null ? filter.getMilestone().id() : null, filter.getAssignee() != null ? filter.getAssignee().id() : null, filter.isOpen(), filter.getDirection(), filter.getSortType());
    return Single.just(filter);
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Label(com.meisolsson.githubsdk.model.Label)

Example 35 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class IssueFragment method openPullRequestCommits.

private void openPullRequestCommits() {
    if (IssueUtils.isPullRequest(issue)) {
        PullRequest pullRequest = issue.pullRequest();
        String base = pullRequest.base().sha();
        String head = pullRequest.head().sha();
        Repository repo = pullRequest.base().repo();
        startActivity(CommitCompareViewActivity.createIntent(repo, base, head));
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) PullRequest(com.meisolsson.githubsdk.model.PullRequest)

Aggregations

Repository (com.meisolsson.githubsdk.model.Repository)68 User (com.meisolsson.githubsdk.model.User)18 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)9 Issue (com.meisolsson.githubsdk.model.Issue)9 Intent (android.content.Intent)8 View (android.view.View)8 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 LayoutInflater (android.view.LayoutInflater)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Test (org.junit.Test)4 Uri (android.net.Uri)3 Menu (android.view.Menu)3 ViewGroup (android.view.ViewGroup)3 LinearLayout (android.widget.LinearLayout)3 R (com.gh4a.R)3 RepositoryActivity (com.gh4a.activities.RepositoryActivity)3 UserActivity (com.gh4a.activities.UserActivity)3 ApiHelpers (com.gh4a.utils.ApiHelpers)3