Skip to content

Commit

Permalink
Merge pull request #770 from sladyn98/change_url_methods
Browse files Browse the repository at this point in the history
Change withURLPath to setRawURLPath
  • Loading branch information
bitwiseman authored Apr 27, 2020
2 parents 6c6eef5 + 3b51e87 commit 2c8c678
Show file tree
Hide file tree
Showing 29 changed files with 1,599 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public URL getProtectionUrl() {
* the io exception
*/
public GHBranchProtection getProtection() throws IOException {
return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
return root.createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
}

/**
Expand All @@ -120,7 +120,7 @@ public String getSHA1() {
* if disabling protection fails
*/
public void disableProtection() throws IOException {
root.createRequest().method("DELETE").withUrlPath(protection_url).send();
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/org/kohsuke/github/GHBranchProtectionTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public void testEnableProtectionOnly() throws Exception {
assertTrue(repo.getBranch(BRANCH).isProtected());
}

@Test
public void testDisableProtectionOnly() throws Exception {
GHBranchProtection protection = branch.enableProtection().enable();
assertTrue(repo.getBranch(BRANCH).isProtected());
branch.disableProtection();
assertFalse(repo.getBranch(BRANCH).isProtected());
}

@Test
public void testEnableRequireReviewsOnly() throws Exception {
GHBranchProtection protection = branch.enableProtection().requireReviews().enable();
Expand All @@ -73,4 +81,12 @@ public void testSignedCommits() throws Exception {
protection.disableSignedCommits();
assertFalse(protection.getRequiredSignatures());
}

@Test
public void testGetProtection() throws Exception {
GHBranchProtection protection = branch.enableProtection().enable();
GHBranchProtection protectionTest = repo.getBranch(BRANCH).getProtection();
assertTrue(protectionTest instanceof GHBranchProtection);
assertTrue(repo.getBranch(BRANCH).isProtected());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"id": 258288342,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTgyODgzNDI=",
"name": "temp-testDisableProtectionOnly",
"full_name": "github-api-test-org/temp-testDisableProtectionOnly",
"private": false,
"owner": {
"login": "github-api-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/github-api-test-org",
"html_url": "https://github.com/github-api-test-org",
"followers_url": "https://api.github.com/users/github-api-test-org/followers",
"following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/github-api-test-org/orgs",
"repos_url": "https://api.github.com/users/github-api-test-org/repos",
"events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-api-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly",
"description": "A test repository for testing the github-api project: temp-testDisableProtectionOnly",
"fork": false,
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly",
"forks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/forks",
"keys_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/teams",
"hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/hooks",
"issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/events{/number}",
"events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/events",
"assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/assignees{/user}",
"branches_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches{/branch}",
"tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/tags",
"blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/statuses/{sha}",
"languages_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/languages",
"stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/stargazers",
"contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contributors",
"subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscribers",
"subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscription",
"commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contents/{+path}",
"compare_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/merges",
"archive_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/downloads",
"issues_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues{/number}",
"pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/pulls{/number}",
"milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/milestones{/number}",
"notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/labels{/name}",
"releases_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/releases{/id}",
"deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/deployments",
"created_at": "2020-04-23T17:59:02Z",
"updated_at": "2020-04-23T17:59:06Z",
"pushed_at": "2020-04-23T17:59:04Z",
"git_url": "git://github.com/github-api-test-org/temp-testDisableProtectionOnly.git",
"ssh_url": "[email protected]:github-api-test-org/temp-testDisableProtectionOnly.git",
"clone_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly.git",
"svn_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly",
"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,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": null,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"organization": {
"login": "github-api-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/github-api-test-org",
"html_url": "https://github.com/github-api-test-org",
"followers_url": "https://api.github.com/users/github-api-test-org/followers",
"following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/github-api-test-org/orgs",
"repos_url": "https://api.github.com/users/github-api-test-org/repos",
"events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-api-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 0,
"subscribers_count": 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "master",
"commit": {
"sha": "dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"node_id": "MDY6Q29tbWl0MjU4Mjg4MzQyOmRkOGNlMjUwMzRlODU5NzNhOGNmYWNiMWIzNzk1NzFlYTNiNGE4YTY=",
"commit": {
"author": {
"name": "Liam Newman",
"email": "[email protected]",
"date": "2020-04-23T17:59:03Z"
},
"committer": {
"name": "GitHub",
"email": "[email protected]",
"date": "2020-04-23T17:59:03Z"
},
"message": "Initial commit",
"tree": {
"sha": "e0f408fb90498b93fb29f15f65a716d635b935aa",
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa"
},
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"comment_count": 0,
"verification": {
"verified": true,
"reason": "valid",
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeoddnCRBK7hj4Ov3rIwAAdHIIAIv1r34nroEHWPNwCvI3P/A7\ng3nDhupwv9OerOc+bvMeovLfsKIkpiHmz3qESI2ei5XL6ZNPffbhe1w7GG8ISF5g\ncJLQ84D+qk/rcOni3PJZj2n/3ChB+//lid6Op2O6TUuZ1omoxIeNzurIUJ7H0gux\nUB0siDrXMc5XXZw5kGQBWwVbc0HVB6lyxQ6s1Ct8w3KgcEGkxv97QsAVR7SvKir2\naI/uu0TB61KnsKh5igvGyT5i+a+fgMXsyV9i/qGSCvoueehSRa5XUHWD8hyDJOBG\nXwOzn696UNyl+0xZo/zHq2fyTeJY8siEyASpAh4KQkGbSHYNakLu+vxzwBB9U28=\n=3X5V\n-----END PGP SIGNATURE-----\n",
"payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Liam Newman <[email protected]> 1587664743 -0700\ncommitter GitHub <[email protected]> 1587664743 -0700\n\nInitial commit"
}
},
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6/comments",
"author": {
"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
},
"committer": {
"login": "web-flow",
"id": 19864447,
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/web-flow",
"html_url": "https://github.com/web-flow",
"followers_url": "https://api.github.com/users/web-flow/followers",
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
"organizations_url": "https://api.github.com/users/web-flow/orgs",
"repos_url": "https://api.github.com/users/web-flow/repos",
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
"received_events_url": "https://api.github.com/users/web-flow/received_events",
"type": "User",
"site_admin": false
},
"parents": []
},
"_links": {
"self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master",
"html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master"
},
"protected": false,
"protection": {
"enabled": false,
"required_status_checks": {
"enforcement_level": "off",
"contexts": []
}
},
"protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "master",
"commit": {
"sha": "dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"node_id": "MDY6Q29tbWl0MjU4Mjg4MzQyOmRkOGNlMjUwMzRlODU5NzNhOGNmYWNiMWIzNzk1NzFlYTNiNGE4YTY=",
"commit": {
"author": {
"name": "Liam Newman",
"email": "[email protected]",
"date": "2020-04-23T17:59:03Z"
},
"committer": {
"name": "GitHub",
"email": "[email protected]",
"date": "2020-04-23T17:59:03Z"
},
"message": "Initial commit",
"tree": {
"sha": "e0f408fb90498b93fb29f15f65a716d635b935aa",
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa"
},
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"comment_count": 0,
"verification": {
"verified": true,
"reason": "valid",
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeoddnCRBK7hj4Ov3rIwAAdHIIAIv1r34nroEHWPNwCvI3P/A7\ng3nDhupwv9OerOc+bvMeovLfsKIkpiHmz3qESI2ei5XL6ZNPffbhe1w7GG8ISF5g\ncJLQ84D+qk/rcOni3PJZj2n/3ChB+//lid6Op2O6TUuZ1omoxIeNzurIUJ7H0gux\nUB0siDrXMc5XXZw5kGQBWwVbc0HVB6lyxQ6s1Ct8w3KgcEGkxv97QsAVR7SvKir2\naI/uu0TB61KnsKh5igvGyT5i+a+fgMXsyV9i/qGSCvoueehSRa5XUHWD8hyDJOBG\nXwOzn696UNyl+0xZo/zHq2fyTeJY8siEyASpAh4KQkGbSHYNakLu+vxzwBB9U28=\n=3X5V\n-----END PGP SIGNATURE-----\n",
"payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Liam Newman <[email protected]> 1587664743 -0700\ncommitter GitHub <[email protected]> 1587664743 -0700\n\nInitial commit"
}
},
"url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6",
"comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6/comments",
"author": {
"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
},
"committer": {
"login": "web-flow",
"id": 19864447,
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/web-flow",
"html_url": "https://github.com/web-flow",
"followers_url": "https://api.github.com/users/web-flow/followers",
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
"organizations_url": "https://api.github.com/users/web-flow/orgs",
"repos_url": "https://api.github.com/users/web-flow/repos",
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
"received_events_url": "https://api.github.com/users/web-flow/received_events",
"type": "User",
"site_admin": false
},
"parents": []
},
"_links": {
"self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master",
"html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master"
},
"protected": true,
"protection": {
"enabled": true,
"required_status_checks": {
"enforcement_level": "off",
"contexts": []
}
},
"protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection"
}
Loading

0 comments on commit 2c8c678

Please sign in to comment.