hub4j / github-api

Java API for GitHub
https://github-api.kohsuke.org/
MIT License
1.12k stars 718 forks source link

Add Support for Retrieving Template Repository Information for a Repo… #1817

Closed jbenaventem closed 4 months ago

jbenaventem commented 4 months ago

Description

Add Support for Retrieving Template Repository Information for a Repository #1812

Before submitting a PR:

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 80.71%. Comparing base (1aa7178) to head (2105263). Report is 4 commits behind head on main.

:exclamation: Current head 2105263 differs from pull request most recent head 88cfdad. Consider uploading reports for the commit 88cfdad to get more accurate results

Files Patch % Lines
src/main/java/org/kohsuke/github/GHRepository.java 50.00% 2 Missing :warning:
...n/java/org/kohsuke/github/GHRepositoryBuilder.java 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1817 +/- ## ============================================ + Coverage 80.66% 80.71% +0.04% - Complexity 2342 2345 +3 ============================================ Files 220 221 +1 Lines 7082 7119 +37 Branches 379 384 +5 ============================================ + Hits 5713 5746 +33 - Misses 1132 1136 +4 Partials 237 237 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jbenaventem commented 4 months ago

@gsmet Thank you for the review. I've resolved almost comments. About this comment

Also I suspect you will have to inject the root in the repository, unless it's done automatically by Jackson. In any case, adding a test to test that you can actually execute an operation on the repository after getting it would be better.

I'm not sure if with this solution provided is enought or you're waiting something more.....

/**
 * Test get repository created from a template repository
 *
 * @throws Exception
 *             the exception
 */
@Test
public void testGetRepositoryWithTemplateRepositoryInfo() throws Exception {
    GHRepository testRepo = gitHub.getRepositoryById(repo.getId());
    assertThat(testRepo.getTemplateRepository(), notNullValue());
    assertThat(testRepo.getTemplateRepository().getOwnerName(), equalTo("octocat"));
    assertThat(testRepo.getTemplateRepository().isTemplate(), equalTo(true));
}