Skip to content

Commit

Permalink
update fork tests from personal to org account
Browse files Browse the repository at this point in the history
  • Loading branch information
Alaurant committed Dec 14, 2024
1 parent 8a8d235 commit bdb8131
Show file tree
Hide file tree
Showing 97 changed files with 6,334 additions and 3,506 deletions.
44 changes: 29 additions & 15 deletions src/test/java/org/kohsuke/github/GHRepositoryForkBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,36 @@ public GHRepositoryForkBuilderTest() {
*/
@Before
public void setUp() throws Exception {
repo = gitHub.getRepository("TestDitto/test-repo");
if (repo == null) {
throw new IllegalStateException("Failed to initialize repository");
repo = getTempRepository();

String defaultBranch = repo.getDefaultBranch();
GHRef mainRef = repo.getRef("heads/" + defaultBranch);
String mainSha = mainRef.getObject().getSha();

String[] branchNames = { "test-branch1", "test-branch2", "test-branch3" };
for (String branchName : branchNames) {
repo.createRef("refs/heads/" + branchName, mainSha);
}
}

private void verifyBasicForkProperties(GHRepository original, GHRepository forked, String expectedName)
throws IOException {
throws IOException, InterruptedException {
assertThat(forked, notNullValue());
assertThat(forked.getName(), equalTo(expectedName));
assertThat(forked.isFork(), is(true));
assertThat(forked.getParent().getFullName(), equalTo(original.getFullName()));

GHRepository updatedFork = forked;
for (int i = 0; i < 10; i++) {
Thread.sleep(3000);
updatedFork = gitHub.getRepository(forked.getFullName());
if (updatedFork.isFork()) {
break;
}
}
}

private void verifyBranches(GHRepository original, GHRepository forked, boolean defaultBranchOnly)
throws IOException {
private void verifyBranches(GHRepository forked, boolean defaultBranchOnly) throws IOException {
Map<String, GHBranch> branches = forked.getBranches();
if (defaultBranchOnly) {
assertThat(branches.size(), equalTo(1));
Expand All @@ -67,9 +81,9 @@ public void testFork() throws Exception {
// GHRepository forkedRepo = repo.createFork().create();
GHRepository forkedRepo = repo.fork();

Thread.sleep(30000);
Thread.sleep(3000);
verifyBasicForkProperties(repo, forkedRepo, repo.getName());
verifyBranches(repo, forkedRepo, false);
verifyBranches(forkedRepo, false);

forkedRepo.delete();
}
Expand All @@ -86,9 +100,9 @@ public void testForkToOrg() throws Exception {
// GHRepository forkedRepo = repo.createFork().organization(targetOrg).create();
GHRepository forkedRepo = repo.forkTo(targetOrg);

Thread.sleep(30000);
Thread.sleep(3000);
verifyBasicForkProperties(repo, forkedRepo, repo.getName());
verifyBranches(repo, forkedRepo, false);
verifyBranches(forkedRepo, false);

forkedRepo.delete();
}
Expand All @@ -103,9 +117,9 @@ public void testForkToOrg() throws Exception {
public void testForkDefaultBranchOnly() throws Exception {
GHRepository forkedRepo = repo.createFork().defaultBranchOnly(true).create();

Thread.sleep(30000);
Thread.sleep(3000);
verifyBasicForkProperties(repo, forkedRepo, repo.getName());
verifyBranches(repo, forkedRepo, true);
verifyBranches(forkedRepo, true);

forkedRepo.delete();
}
Expand All @@ -118,13 +132,13 @@ public void testForkDefaultBranchOnly() throws Exception {
*/
@Test
public void testForkChangedName() throws Exception {
String newRepoName = "new-fork";
String newRepoName = "test-fork-with-new-name";
GHRepository forkedRepo = repo.createFork().name(newRepoName).create();

Thread.sleep(30000);
Thread.sleep(3000);
assertThat(forkedRepo.getName(), equalTo(newRepoName));
verifyBasicForkProperties(repo, forkedRepo, newRepoName);
verifyBranches(repo, forkedRepo, false);
verifyBranches(forkedRepo, false);

forkedRepo.delete();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{
"name": "main",
"commit": {
"sha": "ec1b25ba49597dfa05bca2f7f63b98fedc14712a",
"url": "https://api.github.com/repos/Alaurant/temp-testFork/commits/ec1b25ba49597dfa05bca2f7f63b98fedc14712a"
},
"protected": false,
"protection": {
"enabled": false,
"required_status_checks": {
"enforcement_level": "off",
"contexts": [],
"checks": []
}
},
"protection_url": "https://api.github.com/repos/Alaurant/temp-testFork/branches/main/protection"
},
{
"name": "test-branch1",
"commit": {
"sha": "ec1b25ba49597dfa05bca2f7f63b98fedc14712a",
"url": "https://api.github.com/repos/Alaurant/temp-testFork/commits/ec1b25ba49597dfa05bca2f7f63b98fedc14712a"
},
"protected": false,
"protection": {
"enabled": false,
"required_status_checks": {
"enforcement_level": "off",
"contexts": [],
"checks": []
}
},
"protection_url": "https://api.github.com/repos/Alaurant/temp-testFork/branches/test-branch1/protection"
},
{
"name": "test-branch2",
"commit": {
"sha": "ec1b25ba49597dfa05bca2f7f63b98fedc14712a",
"url": "https://api.github.com/repos/Alaurant/temp-testFork/commits/ec1b25ba49597dfa05bca2f7f63b98fedc14712a"
},
"protected": false,
"protection": {
"enabled": false,
"required_status_checks": {
"enforcement_level": "off",
"contexts": [],
"checks": []
}
},
"protection_url": "https://api.github.com/repos/Alaurant/temp-testFork/branches/test-branch2/protection"
},
{
"name": "test-branch3",
"commit": {
"sha": "ec1b25ba49597dfa05bca2f7f63b98fedc14712a",
"url": "https://api.github.com/repos/Alaurant/temp-testFork/commits/ec1b25ba49597dfa05bca2f7f63b98fedc14712a"
},
"protected": false,
"protection": {
"enabled": false,
"required_status_checks": {
"enforcement_level": "off",
"contexts": [],
"checks": []
}
},
"protection_url": "https://api.github.com/repos/Alaurant/temp-testFork/branches/test-branch3/protection"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"id": 903272099,
"node_id": "R_kgDONdbWow",
"name": "temp-testFork",
"full_name": "hub4j-test-org/temp-testFork",
"private": false,
"owner": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars.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",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/hub4j-test-org/temp-testFork",
"description": "A test repository for testing the github-api project: temp-testFork",
"fork": false,
"url": "https://api.github.com/repos/hub4j-test-org/temp-testFork",
"forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/forks",
"keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/teams",
"hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/events",
"assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/tags",
"blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/languages",
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/contributors",
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/subscription",
"commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/merges",
"archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/downloads",
"issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testFork/deployments",
"created_at": "2024-12-14T06:51:30Z",
"updated_at": "2024-12-14T06:51:30Z",
"pushed_at": "2024-12-14T06:51:30Z",
"git_url": "git://github.com/hub4j-test-org/temp-testFork.git",
"ssh_url": "[email protected]:hub4j-test-org/temp-testFork.git",
"clone_url": "https://github.com/hub4j-test-org/temp-testFork.git",
"svn_url": "https://github.com/hub4j-test-org/temp-testFork",
"homepage": "http://github-api.kohsuke.org/",
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": null,
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": true,
"maintain": true,
"push": true,
"triage": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_auto_merge": false,
"delete_branch_on_merge": false,
"allow_update_branch": false,
"use_squash_pr_title_as_default": false,
"squash_merge_commit_message": "COMMIT_MESSAGES",
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"merge_commit_message": "PR_TITLE",
"merge_commit_title": "MERGE_MESSAGE",
"custom_properties": {},
"organization": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars.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",
"user_view_type": "public",
"site_admin": false
},
"security_and_analysis": {
"secret_scanning": {
"status": "disabled"
},
"secret_scanning_push_protection": {
"status": "disabled"
},
"dependabot_security_updates": {
"status": "disabled"
},
"secret_scanning_non_provider_patterns": {
"status": "disabled"
},
"secret_scanning_validity_checks": {
"status": "disabled"
}
},
"network_count": 0,
"subscribers_count": 21
}
Loading

0 comments on commit bdb8131

Please sign in to comment.