-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fork branch sync #1898
Add fork branch sync #1898
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second rounds of feedback, sorry. This is looking good, just a little more to be done.
Thanks!
* @throws IOException | ||
* the io exception | ||
*/ | ||
public GHRepository sync(String branch) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call actually has a return record that could be useful. Example from the docs:
{
"message": "Successfully fetched and fast-forwarded from upstream defunkt:main",
"merge_type": "fast-forward",
"base_branch": "defunkt:main"
}
Check the schema and return a matching record.
@Test | ||
public void sync() throws IOException { | ||
GHRepository r = getRepository(); | ||
r.sync("main"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add slightly more complex tests to cover the returned record and also the error/exception case. (You can do all in one method if you want or separately.)
Sure thanks, I will try to add a new model for the sync response and perform some assertion on it |
I've added the 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this. Thanks!
GHBranchSync sync = r.sync("main"); | ||
fail("Should have thrown an exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an assertThrows()
method that I prefer for this, but I'm going to block merge for it.
Apparently something wrong with javadoc. I will take a look |
Should be fixed, can you restart the workflows please ? |
Hi @bitwiseman Sorry for the ping, but where you able to review again this PR ? It's also update with the default branch Thanks! |
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 😃 |
I'll do a release today. |
Description
Add support for fork sync branch
Fixing #1626
Added two wiremock test and tested a SNAPSHOT version in a WIP PR jenkins-infra/plugin-modernizer-tool#141
I confirm this work by enabling logs and ensuring my fork is sync directly on GitHub
Before submitting a PR:
@link
JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .mvn -D enable-ci clean install site
locally. If this command doesn't succeed, your change will not pass CI.main
. You will create your PR from that branch.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%