Repository: hub4j/github-api
Pull request #1898 (2024-07-17 15:36:49)

Add fork branch sync
# 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:

- [x] Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Add JavaDocs and other comments explaining the behavior. 
- [x] When adding or updating methods that fetch entities, add `@link` JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest . 
- [x] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
- [x] Push your changes to a branch other than `main`. You will create your PR from that branch.

# When creating a PR: 

  - [x] Fill in the "Description" above with clear summary of the changes. This includes:
  - [x] If this PR fixes one or more issues, include "Fixes #<issue number>" lines for each issue. 
  - [x] Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
- [x] All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
- [x] Enable "Allow edits from maintainers".

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](https://github.com/user-attachments/assets/c2bf7f90-2e3e-474e-aacb-81363fe48e45)





codecov[bot]: ## [Codecov](https://app.codecov.io/gh/hub4j/github-api/pull/1898?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j) Report
Attention: Patch coverage is `85.71429%` with `1 line` in your changes missing coverage. Please review.
> Project coverage is 81.05%. Comparing base [(`cab9bbb`)](https://app.codecov.io/gh/hub4j/github-api/commit/cab9bbb8cb37599362cb37f0c278ab262298c59b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j) to head [(`c40f6b9`)](https://app.codecov.io/gh/hub4j/github-api/commit/c40f6b991d7387c35168079974c69f6355860dde?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j).

| [Files](https://app.codecov.io/gh/hub4j/github-api/pull/1898?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j) | Patch % | Lines |
|---|---|---|
| [src/main/java/org/kohsuke/github/GHRepository.java](https://app.codecov.io/gh/hub4j/github-api/pull/1898?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fkohsuke%2Fgithub%2FGHRepository.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j#diff-c3JjL21haW4vamF2YS9vcmcva29oc3VrZS9naXRodWIvR0hSZXBvc2l0b3J5LmphdmE=) | 85.71% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/hub4j/github-api/pull/1898?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##               main    #1898   +/-   ##
=========================================
  Coverage     81.05%   81.05%           
- Complexity     2442     2443    +1     
=========================================
  Files           237      237           
  Lines          7342     7349    +7     
  Branches        398      398           
=========================================
+ Hits           5951     5957    +6     
  Misses         1145     1145           
- Partials        246      247    +1     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/hub4j/github-api/pull/1898?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hub4j).

jonesbusy: 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: Apparently something wrong with javadoc. I will take a look
jonesbusy: Should be fixed, can you restart the workflows please ?
jonesbusy: Hi @bitwiseman Sorry for the ping, but where you able to review again this PR ?

It's also update with the default branch

Thanks!

Patch:
diff --git a/src/main/java/org/kohsuke/github/GHBranchSync.java b/src/main/java/org/kohsuke/github/GHBranchSync.java
new file mode 100644
index 000000000..d03f4a79b
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/GHBranchSync.java
@@ -0,0 +1,90 @@
+package org.kohsuke.github;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * The type Gh branch sync.
+ */
+public class GHBranchSync extends GitHubInteractiveObject {
+
+    /**
+     * The Repository that this branch is in.
+     */
+    private GHRepository owner;
+
+    /**
+     * The message.
+     */
+    private String message;
+
+    /**
+     * The merge type.
+     */
+    private String mergeType;
+
+    /**
+     * The base branch.
+     */
+    private String baseBranch;
+
+    /**
+     * Gets owner.
+     *
+     * @return the repository that this branch is in.
+     */
+    @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+    public GHRepository getOwner() {
+        return owner;
+    }
+
+    /**
+     * Gets message.
+     *
+     * @return the message
+     */
+    public String getMessage() {
+        return message;
+    }
+
+    /**
+     * Gets merge type.
+     *
+     * @return the merge type
+     */
+    public String getMergeType() {
+        return mergeType;
+    }
+
+    /**
+     * Gets base branch.
+     *
+     * @return the base branch
+     */
+    public String getBaseBranch() {
+        return baseBranch;
+    }
+
+    /**
+     * To string.
+     *
+     * @return the string
+     */
+    @Override
+    public String toString() {
+        return "GHBranchSync{" + "message='" + message + '\'' + ", mergeType='" + mergeType + '\'' + ", baseBranch='"
+                + baseBranch + '\'' + '}';
+    }
+
+    /**
+     * Wrap.
+     *
+     * @param repo
+     *            the repo
+     * @return the GH branch sync
+     */
+    GHBranchSync wrap(GHRepository repo) {
+        this.owner = repo;
+        return this;
+    }
+
+}
diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java
index 9dbbb49eb..44bf41d30 100644
--- a/src/main/java/org/kohsuke/github/GHRepository.java
+++ b/src/main/java/org/kohsuke/github/GHRepository.java
@@ -1614,6 +1614,24 @@ public class GHRepository extends GHObject {
         throw new IOException(this + " was forked but can't find the new repository");
     }
 
+    /**
+     * Sync this repository fork branch
+     *
+     * @param branch
+     *            the branch to sync
+     * @return The current repository
+     * @throws IOException
+     *             the io exception
+     */
+    public GHBranchSync sync(String branch) throws IOException {
+        return root().createRequest()
+                .method("POST")
+                .with("branch", branch)
+                .withUrlPath(getApiTailUrl("merge-upstream"))
+                .fetch(GHBranchSync.class)
+                .wrap(this);
+    }
+
     /**
      * Forks this repository into an organization.
      *


Test patch:
diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
index 839f7f188..bb737dbb8 100644
--- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java
+++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
@@ -47,6 +47,36 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
         return gitHub.getOrganization("hub4j-test-org").getRepository("github-api");
     }
 
+    /**
+     * Test sync of fork
+     *
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    @Test
+    public void sync() throws IOException {
+        GHRepository r = getRepository();
+        GHBranchSync sync = r.sync("main");
+        assertThat(sync.getOwner().getFullName(), equalTo("hub4j-test-org/github-api"));
+        assertThat(sync.getMessage(), equalTo("Successfully fetched and fast-forwarded from upstream github-api:main"));
+        assertThat(sync.getMergeType(), equalTo("fast-forward"));
+        assertThat(sync.getBaseBranch(), equalTo("github-api:main"));
+    }
+
+    /**
+     * Test sync of repository not a fork
+     *
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    @Test(expected = HttpException.class)
+    public void syncNoFork() throws IOException {
+        GHRepository r = getRepository();
+        GHBranchSync sync = r.sync("main");
+        fail("Should have thrown an exception");
+
+    }
+
     /**
      * Test zipball.
      *
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/1-user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/1-user.json
new file mode 100644
index 000000000..eab16ea06
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/1-user.json
@@ -0,0 +1,33 @@
+{
+  "login": "bitwiseman",
+  "id": 1958953,
+  "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+  "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
+  "gravatar_id": "",
+  "url": "https://api.github.com/users/bitwiseman",
+  "html_url": "https://github.com/bitwiseman",
+  "followers_url": "https://api.github.com/users/bitwiseman/followers",
+  "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+  "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+  "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+  "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+  "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+  "repos_url": "https://api.github.com/users/bitwiseman/repos",
+  "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+  "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+  "type": "User",
+  "site_admin": false,
+  "name": "Liam Newman",
+  "company": "Cloudbees, Inc.",
+  "blog": "",
+  "location": "Seattle, WA, USA",
+  "email": "bitwiseman@gmail.com",
+  "hireable": null,
+  "bio": "https://twitter.com/bitwiseman",
+  "public_repos": 166,
+  "public_gists": 4,
+  "followers": 135,
+  "following": 9,
+  "created_at": "2012-07-11T20:38:33Z",
+  "updated_at": "2019-09-24T19:32:29Z"
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/2-orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/2-orgs_hub4j-test-org.json
new file mode 100644
index 000000000..f176fc4ff
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/2-orgs_hub4j-test-org.json
@@ -0,0 +1,42 @@
+{
+  "login": "hub4j-test-org",
+  "id": 7544739,
+  "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+  "url": "https://api.github.com/orgs/hub4j-test-org",
+  "repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
+  "events_url": "https://api.github.com/orgs/hub4j-test-org/events",
+  "hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
+  "issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
+  "members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
+  "public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
+  "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+  "description": null,
+  "is_verified": false,
+  "has_organization_projects": true,
+  "has_repository_projects": true,
+  "public_repos": 9,
+  "public_gists": 0,
+  "followers": 0,
+  "following": 0,
+  "html_url": "https://github.com/hub4j-test-org",
+  "created_at": "2014-05-10T19:39:11Z",
+  "updated_at": "2015-04-20T00:42:30Z",
+  "type": "Organization",
+  "total_private_repos": 0,
+  "owned_private_repos": 0,
+  "private_gists": 0,
+  "disk_usage": 132,
+  "collaborators": 0,
+  "billing_email": "kk@kohsuke.org",
+  "default_repository_permission": "none",
+  "members_can_create_repositories": false,
+  "two_factor_requirement_enabled": false,
+  "members_allowed_repository_creation_type": "none",
+  "plan": {
+    "name": "free",
+    "space": 976562499,
+    "private_repos": 0,
+    "filled_seats": 3,
+    "seats": 0
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/3-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/3-r_h_github-api.json
new file mode 100644
index 000000000..d2a3a7aa9
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/3-r_h_github-api.json
@@ -0,0 +1,330 @@
+{
+  "id": 206888201,
+  "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=",
+  "name": "github-api",
+  "full_name": "hub4j-test-org/github-api",
+  "private": false,
+  "owner": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "html_url": "https://github.com/hub4j-test-org/github-api",
+  "description": "Tricky",
+  "fork": true,
+  "url": "https://api.github.com/repos/hub4j-test-org/github-api",
+  "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks",
+  "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}",
+  "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}",
+  "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams",
+  "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks",
+  "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}",
+  "events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events",
+  "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}",
+  "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}",
+  "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags",
+  "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}",
+  "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}",
+  "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}",
+  "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}",
+  "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}",
+  "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages",
+  "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers",
+  "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors",
+  "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers",
+  "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription",
+  "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}",
+  "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}",
+  "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}",
+  "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}",
+  "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}",
+  "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}",
+  "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges",
+  "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}",
+  "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads",
+  "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}",
+  "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}",
+  "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}",
+  "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}",
+  "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}",
+  "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}",
+  "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments",
+  "created_at": "2019-09-06T23:26:04Z",
+  "updated_at": "2019-09-25T23:32:35Z",
+  "pushed_at": "2019-09-21T14:29:14Z",
+  "git_url": "git://github.com/hub4j-test-org/github-api.git",
+  "ssh_url": "git@github.com:hub4j-test-org/github-api.git",
+  "clone_url": "https://github.com/hub4j-test-org/github-api.git",
+  "svn_url": "https://github.com/hub4j-test-org/github-api",
+  "homepage": "http://github-api.kohsuke.org/",
+  "size": 11387,
+  "stargazers_count": 0,
+  "watchers_count": 0,
+  "language": "Java",
+  "has_issues": true,
+  "has_projects": true,
+  "has_downloads": true,
+  "has_wiki": true,
+  "has_pages": false,
+  "forks_count": 0,
+  "mirror_url": null,
+  "archived": false,
+  "disabled": false,
+  "open_issues_count": 0,
+  "license": {
+    "key": "mit",
+    "name": "MIT License",
+    "spdx_id": "MIT",
+    "url": "https://api.github.com/licenses/mit",
+    "node_id": "MDc6TGljZW5zZTEz"
+  },
+  "forks": 0,
+  "open_issues": 0,
+  "watchers": 0,
+  "default_branch": "main",
+  "permissions": {
+    "admin": true,
+    "push": true,
+    "pull": true
+  },
+  "allow_squash_merge": true,
+  "allow_merge_commit": true,
+  "allow_rebase_merge": true,
+  "organization": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "parent": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": true,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-09-25T22:47:32Z",
+    "pushed_at": "2019-09-25T22:56:18Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 11678,
+    "stargazers_count": 553,
+    "watchers_count": 553,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 427,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 96,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 427,
+    "open_issues": 96,
+    "watchers": 553,
+    "default_branch": "main"
+  },
+  "source": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-09-25T22:47:32Z",
+    "pushed_at": "2019-09-25T22:56:18Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 11678,
+    "stargazers_count": 553,
+    "watchers_count": 553,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 427,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 96,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 427,
+    "open_issues": 96,
+    "watchers": 553,
+    "default_branch": "main"
+  },
+  "network_count": 427,
+  "subscribers_count": 0
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/4-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/4-r_h_github-api.json
new file mode 100644
index 000000000..59ae8286f
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/__files/4-r_h_github-api.json
@@ -0,0 +1,5 @@
+{
+  "message": "Successfully fetched and fast-forwarded from upstream github-api:main",
+  "merge_type": "fast-forward",
+  "base_branch": "github-api:main"
+}
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/1-user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/1-user.json
new file mode 100644
index 000000000..a7e5c0c21
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/1-user.json
@@ -0,0 +1,48 @@
+{
+  "id": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "name": "user",
+  "request": {
+    "url": "/user",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "1-user.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:33 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4992",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"14ffd29009ddc2209c450bb29a5a8330\"",
+      "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F845:5D1D:FFA88A:12FE539:5D8BF9C5"
+    }
+  },
+  "uuid": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "persistent": true,
+  "insertionIndex": 1
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/2-orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/2-orgs_hub4j-test-org.json
new file mode 100644
index 000000000..64182cc8c
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/2-orgs_hub4j-test-org.json
@@ -0,0 +1,48 @@
+{
+  "id": "cb173af2-c793-444a-acdf-c3850e7afdbe",
+  "name": "orgs_hub4j-test-org",
+  "request": {
+    "url": "/orgs/hub4j-test-org",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "2-orgs_hub4j-test-org.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:58 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4989",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"b7989d48e6539c9c76038995b902421b\"",
+      "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397ED7:171400E:5D8BF9DE"
+    }
+  },
+  "uuid": "cb173af2-c793-444a-acdf-c3850e7afdbe",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/3-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/3-r_h_github-api.json
new file mode 100644
index 000000000..265e1fd4b
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/3-r_h_github-api.json
@@ -0,0 +1,51 @@
+{
+  "id": "0a4d7a1a-f99c-47ca-840a-3e920c18bd1f",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "3-r_h_github-api.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:58 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4988",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"0678d1c39ea574f68cc0fb330b067cb7\"",
+      "Last-Modified": "Wed, 25 Sep 2019 23:32:35 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397EEB:1714029:5D8BF9DE"
+    }
+  },
+  "uuid": "0a4d7a1a-f99c-47ca-840a-3e920c18bd1f",
+  "persistent": true,
+  "scenarioName": "scenario-1-repos-hub4j-test-org-github-api",
+  "requiredScenarioState": "Started",
+  "newScenarioState": "scenario-1-repos-hub4j-test-org-github-api-2",
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/4-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/4-r_h_github-api.json
new file mode 100644
index 000000000..d3f36a562
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/sync/mappings/4-r_h_github-api.json
@@ -0,0 +1,54 @@
+{
+  "id": "2c69d5c8-dd81-4204-bad9-ee37f5b0ebfd",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api/merge-upstream",
+    "method": "POST",
+    "bodyPatterns": [
+      {
+        "equalToJson": "{\"branch\":\"main\"}",
+        "ignoreArrayOrder": true,
+        "ignoreExtraElements": false
+      }
+    ],
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "4-r_h_github-api.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:59 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4987",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"e40487cafd3670c0de171f4250dbefb8\"",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397F0E:1714041:5D8BF9DE"
+    }
+  },
+  "uuid": "2c69d5c8-dd81-4204-bad9-ee37f5b0ebfd",
+  "persistent": true,
+  "insertionIndex": 4
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/1-user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/1-user.json
new file mode 100644
index 000000000..eab16ea06
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/1-user.json
@@ -0,0 +1,33 @@
+{
+  "login": "bitwiseman",
+  "id": 1958953,
+  "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+  "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
+  "gravatar_id": "",
+  "url": "https://api.github.com/users/bitwiseman",
+  "html_url": "https://github.com/bitwiseman",
+  "followers_url": "https://api.github.com/users/bitwiseman/followers",
+  "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+  "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+  "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+  "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+  "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+  "repos_url": "https://api.github.com/users/bitwiseman/repos",
+  "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+  "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+  "type": "User",
+  "site_admin": false,
+  "name": "Liam Newman",
+  "company": "Cloudbees, Inc.",
+  "blog": "",
+  "location": "Seattle, WA, USA",
+  "email": "bitwiseman@gmail.com",
+  "hireable": null,
+  "bio": "https://twitter.com/bitwiseman",
+  "public_repos": 166,
+  "public_gists": 4,
+  "followers": 135,
+  "following": 9,
+  "created_at": "2012-07-11T20:38:33Z",
+  "updated_at": "2019-09-24T19:32:29Z"
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/2-orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/2-orgs_hub4j-test-org.json
new file mode 100644
index 000000000..f176fc4ff
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/2-orgs_hub4j-test-org.json
@@ -0,0 +1,42 @@
+{
+  "login": "hub4j-test-org",
+  "id": 7544739,
+  "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+  "url": "https://api.github.com/orgs/hub4j-test-org",
+  "repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
+  "events_url": "https://api.github.com/orgs/hub4j-test-org/events",
+  "hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
+  "issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
+  "members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
+  "public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
+  "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+  "description": null,
+  "is_verified": false,
+  "has_organization_projects": true,
+  "has_repository_projects": true,
+  "public_repos": 9,
+  "public_gists": 0,
+  "followers": 0,
+  "following": 0,
+  "html_url": "https://github.com/hub4j-test-org",
+  "created_at": "2014-05-10T19:39:11Z",
+  "updated_at": "2015-04-20T00:42:30Z",
+  "type": "Organization",
+  "total_private_repos": 0,
+  "owned_private_repos": 0,
+  "private_gists": 0,
+  "disk_usage": 132,
+  "collaborators": 0,
+  "billing_email": "kk@kohsuke.org",
+  "default_repository_permission": "none",
+  "members_can_create_repositories": false,
+  "two_factor_requirement_enabled": false,
+  "members_allowed_repository_creation_type": "none",
+  "plan": {
+    "name": "free",
+    "space": 976562499,
+    "private_repos": 0,
+    "filled_seats": 3,
+    "seats": 0
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/3-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/3-r_h_github-api.json
new file mode 100644
index 000000000..2680467bc
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/3-r_h_github-api.json
@@ -0,0 +1,330 @@
+{
+  "id": 206888201,
+  "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=",
+  "name": "github-api",
+  "full_name": "hub4j-test-org/github-api",
+  "private": false,
+  "owner": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "html_url": "https://github.com/hub4j-test-org/github-api",
+  "description": "Tricky",
+  "fork": false,
+  "url": "https://api.github.com/repos/hub4j-test-org/github-api",
+  "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks",
+  "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}",
+  "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}",
+  "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams",
+  "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks",
+  "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}",
+  "events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events",
+  "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}",
+  "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}",
+  "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags",
+  "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}",
+  "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}",
+  "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}",
+  "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}",
+  "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}",
+  "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages",
+  "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers",
+  "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors",
+  "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers",
+  "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription",
+  "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}",
+  "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}",
+  "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}",
+  "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}",
+  "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}",
+  "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}",
+  "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges",
+  "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}",
+  "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads",
+  "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}",
+  "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}",
+  "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}",
+  "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}",
+  "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}",
+  "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}",
+  "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments",
+  "created_at": "2019-09-06T23:26:04Z",
+  "updated_at": "2019-09-25T23:32:35Z",
+  "pushed_at": "2019-09-21T14:29:14Z",
+  "git_url": "git://github.com/hub4j-test-org/github-api.git",
+  "ssh_url": "git@github.com:hub4j-test-org/github-api.git",
+  "clone_url": "https://github.com/hub4j-test-org/github-api.git",
+  "svn_url": "https://github.com/hub4j-test-org/github-api",
+  "homepage": "http://github-api.kohsuke.org/",
+  "size": 11387,
+  "stargazers_count": 0,
+  "watchers_count": 0,
+  "language": "Java",
+  "has_issues": true,
+  "has_projects": true,
+  "has_downloads": true,
+  "has_wiki": true,
+  "has_pages": false,
+  "forks_count": 0,
+  "mirror_url": null,
+  "archived": false,
+  "disabled": false,
+  "open_issues_count": 0,
+  "license": {
+    "key": "mit",
+    "name": "MIT License",
+    "spdx_id": "MIT",
+    "url": "https://api.github.com/licenses/mit",
+    "node_id": "MDc6TGljZW5zZTEz"
+  },
+  "forks": 0,
+  "open_issues": 0,
+  "watchers": 0,
+  "default_branch": "main",
+  "permissions": {
+    "admin": true,
+    "push": true,
+    "pull": true
+  },
+  "allow_squash_merge": true,
+  "allow_merge_commit": true,
+  "allow_rebase_merge": true,
+  "organization": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/hub4j-test-org",
+    "html_url": "https://github.com/hub4j-test-org",
+    "followers_url": "https://api.github.com/users/hub4j-test-org/followers",
+    "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
+    "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
+    "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
+    "repos_url": "https://api.github.com/users/hub4j-test-org/repos",
+    "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
+    "type": "Organization",
+    "site_admin": false
+  },
+  "parent": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": true,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-09-25T22:47:32Z",
+    "pushed_at": "2019-09-25T22:56:18Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 11678,
+    "stargazers_count": 553,
+    "watchers_count": 553,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 427,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 96,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 427,
+    "open_issues": 96,
+    "watchers": 553,
+    "default_branch": "main"
+  },
+  "source": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2019-09-25T22:47:32Z",
+    "pushed_at": "2019-09-25T22:56:18Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 11678,
+    "stargazers_count": 553,
+    "watchers_count": 553,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 427,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 96,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 427,
+    "open_issues": 96,
+    "watchers": 553,
+    "default_branch": "main"
+  },
+  "network_count": 427,
+  "subscribers_count": 0
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/4-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/4-r_h_github-api.json
new file mode 100644
index 000000000..6d0311486
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/__files/4-r_h_github-api.json
@@ -0,0 +1,5 @@
+{
+  "message": "Validation Failed",
+  "documentation_url": "https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository",
+  "status": "422"
+}
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/1-user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/1-user.json
new file mode 100644
index 000000000..a7e5c0c21
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/1-user.json
@@ -0,0 +1,48 @@
+{
+  "id": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "name": "user",
+  "request": {
+    "url": "/user",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "1-user.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:33 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4992",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"14ffd29009ddc2209c450bb29a5a8330\"",
+      "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F845:5D1D:FFA88A:12FE539:5D8BF9C5"
+    }
+  },
+  "uuid": "7f6e9a01-5bfa-4f72-9947-07df902f56c3",
+  "persistent": true,
+  "insertionIndex": 1
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/2-orgs_hub4j-test-org.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/2-orgs_hub4j-test-org.json
new file mode 100644
index 000000000..64182cc8c
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/2-orgs_hub4j-test-org.json
@@ -0,0 +1,48 @@
+{
+  "id": "cb173af2-c793-444a-acdf-c3850e7afdbe",
+  "name": "orgs_hub4j-test-org",
+  "request": {
+    "url": "/orgs/hub4j-test-org",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "2-orgs_hub4j-test-org.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:58 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4989",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"b7989d48e6539c9c76038995b902421b\"",
+      "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397ED7:171400E:5D8BF9DE"
+    }
+  },
+  "uuid": "cb173af2-c793-444a-acdf-c3850e7afdbe",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/3-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/3-r_h_github-api.json
new file mode 100644
index 000000000..265e1fd4b
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/3-r_h_github-api.json
@@ -0,0 +1,51 @@
+{
+  "id": "0a4d7a1a-f99c-47ca-840a-3e920c18bd1f",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "3-r_h_github-api.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:58 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4988",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"0678d1c39ea574f68cc0fb330b067cb7\"",
+      "Last-Modified": "Wed, 25 Sep 2019 23:32:35 GMT",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397EEB:1714029:5D8BF9DE"
+    }
+  },
+  "uuid": "0a4d7a1a-f99c-47ca-840a-3e920c18bd1f",
+  "persistent": true,
+  "scenarioName": "scenario-1-repos-hub4j-test-org-github-api",
+  "requiredScenarioState": "Started",
+  "newScenarioState": "scenario-1-repos-hub4j-test-org-github-api-2",
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/4-r_h_github-api.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/4-r_h_github-api.json
new file mode 100644
index 000000000..ec44fcf0d
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/syncNoFork/mappings/4-r_h_github-api.json
@@ -0,0 +1,54 @@
+{
+  "id": "2c69d5c8-dd81-4204-bad9-ee37f5b0ebfd",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api/merge-upstream",
+    "method": "POST",
+    "bodyPatterns": [
+      {
+        "equalToJson": "{\"branch\":\"main\"}",
+        "ignoreArrayOrder": true,
+        "ignoreExtraElements": false
+      }
+    ],
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github+json"
+      }
+    }
+  },
+  "response": {
+    "status": 422,
+    "bodyFileName": "4-r_h_github-api.json",
+    "headers": {
+      "Date": "Wed, 25 Sep 2019 23:35:59 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "422 Unprocessable Entity",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4987",
+      "X-RateLimit-Reset": "1569457884",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"e40487cafd3670c0de171f4250dbefb8\"",
+      "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo",
+      "X-Accepted-OAuth-Scopes": "",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F855:59E1:1397F0E:1714041:5D8BF9DE"
+    }
+  },
+  "uuid": "2c69d5c8-dd81-4204-bad9-ee37f5b0ebfd",
+  "persistent": true,
+  "insertionIndex": 4
+}
\ No newline at end of file