hub4j / github-api

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

Add fork branch sync #1898

Closed jonesbusy closed 1 month ago

jonesbusy commented 1 month ago

Description

Add support for fork sync branch

Fixing https://github.com/hub4j/github-api/issues/1626

Added two wiremock test and tested a SNAPSHOT version in a WIP PR https://github.com/jenkinsci/plugin-modernizer-tool/pull/141

I confirm this work by enabling logs and ensuring my fork is sync directly on GitHub

(e24ddd0) GitHub API request: POST https://api.github.com/repos/jonesbusy/jobcacher-plugin/merge-upstream 

Before submitting a PR:

When creating a PR:

API is https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#sync-a-fork-branch-with-the-upstream-repository

Code is covered 100%

Screenshot from 2024-07-24 12-38-45

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.32%. Comparing base (3c4d80c) to head (6493b2c).

Files Patch % Lines
src/main/java/org/kohsuke/github/GHBranchSync.java 87.50% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1898 +/- ## ============================================ + Coverage 81.29% 81.32% +0.02% - Complexity 2450 2457 +7 ============================================ Files 238 239 +1 Lines 7449 7463 +14 Branches 400 400 ============================================ + Hits 6056 6069 +13 - Misses 1146 1147 +1 Partials 247 247 ```

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

jonesbusy commented 1 month ago

Sure thanks, I will try to add a new model for the sync response and perform some assertion on it

jonesbusy commented 1 month ago

I've added the GHBranchSync model and return it

I've also added a negative test when the API return a non-200 status code (for example 422 when the repo is not a fork)

jonesbusy commented 1 month ago

Apparently something wrong with javadoc. I will take a look

jonesbusy commented 1 month ago

Should be fixed, can you restart the workflows please ?

jonesbusy commented 1 month ago

Hi @bitwiseman Sorry for the ping, but where you able to review again this PR ?

It's also update with the default branch

Thanks!

jonesbusy commented 2 weeks ago

Thanks for the merge @bitwiseman. Sorry to ping you directly (again) but is there a release soon including this feature ?

I'm asking because we are approaching the end of the Google Summer of Code on our project https://github.com/jenkinsci/plugin-modernizer-tool and would be great that we can include the new release on our delivery

The fork sync is quiet critical on our project to avoid opening PRs from outdated forks.

Thanks for your consideration 😃

bitwiseman commented 2 weeks ago

I'll do a release today.