Skip to content

Commit b8e128d

Browse files
bobeaganacrobat
authored andcommitted
add missing protection methods, docs and tests (#616)
* add missing protection methods, docs and tests * fix style issues * fix failing test * update changelog
1 parent d864754 commit b8e128d

File tree

4 files changed

+1004
-23
lines changed

4 files changed

+1004
-23
lines changed

CHANGELOG.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Change Log
22

3-
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
3+
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

55
## 2.6.0 (unreleased)
66

77
### Added
88

99
- Support for graphql api [variables](https://developer.github.com/v4/guides/forming-calls/#working-with-variables) (#612)
10+
- Added missing branch protection methods (#616)
1011

1112
## 2.5.0
1213

@@ -25,15 +26,15 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
2526

2627
### Added
2728

28-
- `Integrations::configure` to allow accessing early access program endpoints.
29+
- `Integrations::configure` to allow accessing early access program endpoints.
2930
- Add support for pagination and parameters in the pull request comments
3031
- Add the ability to fetch user installations (`CurrentUser::installations`)
3132
- Allow getting repo info by id (`Repo::showById`)
3233
- Allow fetching repositories for a specific installation and user (`CurrentUser::repositoriesByInstallation`)
3334

3435
### Changed
3536

36-
- `PullRequest\Review` and `PullRequest\ReviewRequest` is now part of the official API. No need to call `configure`.
37+
- `PullRequest\Review` and `PullRequest\ReviewRequest` is now part of the official API. No need to call `configure`.
3738

3839
## 2.3.0
3940

@@ -49,18 +50,18 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
4950

5051
### Changed
5152

52-
- First argument to `Integrations::listRepositories()` is now optional.
53+
- First argument to `Integrations::listRepositories()` is now optional.
5354
- Moved tests from "functional" to "integration"
5455

5556
## 2.2.0
5657

5758
### Added
5859

5960
- API support for Pull Request Review Requests.
60-
- API support for Traffic.
61-
- API support for issue Assignees.
62-
- API support for Miscellaneous Gitignore and Emojis.
63-
- Added endpoints for issue lock, unlock and issue label show.
61+
- API support for Traffic.
62+
- API support for issue Assignees.
63+
- API support for Miscellaneous Gitignore and Emojis.
64+
- Added endpoints for issue lock, unlock and issue label show.
6465
- Added more parameters to `User::starred`.
6566
- Fluid interface by allowing `configure()` to return `$this`.
6667
- `configure()` support for issues API.
@@ -74,21 +75,21 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
7475

7576
### Added
7677

77-
- Add support for retrieving a single notification info using his ID
78+
- Add support for retrieving a single notification info using his ID
7879
- Add a function to get user organizations
7980
- Added GraphQL support
8081
- Add page variable to organization repo list (Organization::repositories())
81-
- Add support for pull request review.
82+
- Add support for pull request review.
8283
- Add support for adding branch protection.
8384

8485
### Fixed
8586

86-
- Bug with double slashes when using enterprise URL.
87+
- Bug with double slashes when using enterprise URL.
8788
- Bug when headers not being passed to request (#529)
8889

8990
## 2.0.0
9091

91-
### Added
92+
### Added
9293

9394
- Support for JWT authentication
9495
- API for Organization\Members
@@ -101,26 +102,26 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
101102

102103
### Changed
103104

104-
- `ApiLimitExceedException::__construct` has a new second parameter for the remaining API calls.
105-
- First parameter of `Github\Client` has changed type from `\Http\Client\HttpClient` to
106-
`Github\HttpClient\Builder`. A factory class was also added. To upgrade you need to change:
107-
105+
- `ApiLimitExceedException::__construct` has a new second parameter for the remaining API calls.
106+
- First parameter of `Github\Client` has changed type from `\Http\Client\HttpClient` to
107+
`Github\HttpClient\Builder`. A factory class was also added. To upgrade you need to change:
108+
108109
```php
109110
// Old way does not work:
110-
$github = new Github\Client($httpClient);
111+
$github = new Github\Client($httpClient);
111112

112113
// New way will work:
113-
$github = new Github\Client(new Github\HttpClient\Builder($httpClient));
114-
$github = Github\Client::createWithHttpClient($httpClient);
114+
$github = new Github\Client(new Github\HttpClient\Builder($httpClient));
115+
$github = Github\Client::createWithHttpClient($httpClient);
115116
```
116-
- Renamed the currentuser `DeployKeys` api class to `PublicKeys` to reflect to github api name.
117+
- Renamed the currentuser `DeployKeys` api class to `PublicKeys` to reflect to github api name.
117118

118119
## 2.0.0-rc4
119120

120-
### Added
121+
### Added
121122

122123
- HTTPlug to decouple from Guzzle
123-
- `Github\Client::getLastResponse` was added
124+
- `Github\Client::getLastResponse` was added
124125
- Support for PSR-6 cache
125126
- `Github\Client::addPlugin` and `Github\Client::removePlugin`
126127
- `Github\Client::getApiVersion`
@@ -143,6 +144,6 @@ $github = Github\Client::createWithHttpClient($httpClient);
143144
- `Github/HttpClient/CachedHttpClient` was removed
144145
- All classes in `Github/HttpClient/Cache/*` were removed
145146

146-
## 1.7.1
147+
## 1.7.1
147148

148149
No change log before this version

doc/repo/protection.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,233 @@ $protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'mas
4141
```php
4242
$protection = $client->api('repo')->protection()->remove('twbs', 'bootstrap', 'master');
4343
```
44+
45+
### Get required status checks of protected branch
46+
47+
> Requires [authentication](../security.md).
48+
49+
```php
50+
$protection = $client->api('repo')->protection()->showStatusChecks('twbs', 'bootstrap', 'master');
51+
```
52+
53+
### Update required status checks of protected branch
54+
55+
> Requires [authentication](../security.md).
56+
57+
```php
58+
$params = [
59+
'strict' => true,
60+
'contexts' => [
61+
'continuous-integration/travis-ci',
62+
],
63+
];
64+
$protection = $client->api('repo')->protection()->updateStatusChecks('twbs', 'bootstrap', 'master', $params);
65+
```
66+
67+
### Remove required status checks of protected branch
68+
69+
> Requires [authentication](../security.md).
70+
71+
```php
72+
$protection = $client->api('repo')->protection()->removeStatusChecks('twbs', 'bootstrap', 'master');
73+
```
74+
75+
### List required status checks contexts of protected branch
76+
77+
> Requires [authentication](../security.md).
78+
79+
```php
80+
$protection = $client->api('repo')->protection()->showStatusChecksContexts('twbs', 'bootstrap', 'master');
81+
```
82+
83+
### Replace required status checks contexts of protected branch
84+
85+
> Requires [authentication](../security.md).
86+
87+
```php
88+
$params = [
89+
'continuous-integration/travis-ci',
90+
];
91+
$protection = $client->api('repo')->protection()->replaceStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
92+
```
93+
94+
### Add required status checks contexts of protected branch
95+
96+
> Requires [authentication](../security.md).
97+
98+
```php
99+
$params = [
100+
'continuous-integration/jenkins',
101+
];
102+
$protection = $client->api('repo')->protection()->addStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
103+
```
104+
105+
### Remove required status checks contexts of protected branch
106+
107+
> Requires [authentication](../security.md).
108+
109+
```php
110+
$params = [
111+
'continuous-integration/jenkins',
112+
];
113+
$protection = $client->api('repo')->protection()->removeStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
114+
```
115+
116+
### Get pull request review enforcement of protected branch
117+
118+
> Requires [authentication](../security.md).
119+
120+
```php
121+
$protection = $client->api('repo')->protection()->showPullRequestReviewEnforcement('twbs', 'bootstrap', 'master');
122+
```
123+
124+
### Update pull request review enforcement of protected branch
125+
126+
> Requires [authentication](../security.md) with admin access and branch protection to be enabled.
127+
128+
```php
129+
$params = [
130+
'dismissal_restrictions' => [
131+
'users' => [
132+
'octocat',
133+
],
134+
'teams' => [
135+
'justice-league',
136+
],
137+
],
138+
'dismiss_stale_reviews' => true,
139+
'require_code_owner_reviews' => true,
140+
];
141+
$protection = $client->api('repo')->protection()->updatePullRequestReviewEnforcement('twbs', 'bootstrap', 'master', $params);
142+
```
143+
144+
### Remove pull request review enforcement of protected branch
145+
146+
> Requires [authentication](../security.md).
147+
148+
```php
149+
$protection = $client->api('repo')->protection()->removePullRequestReviewEnforcement('twbs', 'bootstrap', 'master');
150+
```
151+
152+
### Get admin enforcement of protected branch
153+
154+
155+
> Requires [authentication](../security.md).
156+
157+
```php
158+
$protection = $client->api('repo')->protection()->showAdminEnforcement('twbs', 'bootstrap', 'master');
159+
```
160+
161+
### Add admin enforcement of protected branch
162+
163+
> Requires [authentication](../security.md) with admin access and branch protection to be enabled.
164+
165+
```php
166+
$protection = $client->api('repo')->protection()->addAdminEnforcement('twbs', 'bootstrap', 'master');
167+
```
168+
169+
### Remove admin enforcement of protected branch
170+
171+
> Requires [authentication](../security.md) with admin access and branch protection to be enabled.
172+
173+
```php
174+
$protection = $client->api('repo')->protection()->removeAdminEnforcement('twbs', 'bootstrap', 'master');
175+
```
176+
177+
### Get restrictions of protected branch
178+
179+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
180+
181+
```php
182+
$protection = $client->api('repo')->protection()->showRestrictions('twbs', 'bootstrap', 'master');
183+
```
184+
185+
### Remove restrictions of protected branch
186+
187+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
188+
189+
```php
190+
$protection = $client->api('repo')->protection()->removeRestrictions('twbs', 'bootstrap', 'master');
191+
```
192+
193+
### List team restrictions of protected branch
194+
195+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
196+
197+
```php
198+
$protection = $client->api('repo')->protection()->showTeamRestrictions('twbs', 'bootstrap', 'master');
199+
```
200+
201+
### Replace team restrictions of protected branch
202+
203+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
204+
205+
```php
206+
$params = [
207+
'justice-league',
208+
];
209+
$protection = $client->api('repo')->protection()->replaceTeamRestrictions('twbs', 'bootstrap', 'master', $params);
210+
```
211+
212+
### Add team restrictions of protected branch
213+
214+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
215+
216+
```php
217+
$params = [
218+
'justice-league',
219+
];
220+
$protection = $client->api('repo')->protection()->addTeamRestrictions('twbs', 'bootstrap', 'master', $params);
221+
```
222+
223+
### Remove team restrictions of protected branch
224+
225+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
226+
227+
```php
228+
$params = [
229+
'octocats',
230+
];
231+
$protection = $client->api('repo')->protection()->removeTeamRestrictions('twbs', 'bootstrap', 'master', $params);
232+
```
233+
234+
### List user restrictions of protected branch
235+
236+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
237+
238+
```php
239+
$protection = $client->api('repo')->protection()->showUserRestrictions('twbs', 'bootstrap', 'master');
240+
```
241+
242+
### Replace user restrictions of protected branch
243+
244+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
245+
246+
```php
247+
$params = [
248+
'octocat',
249+
];
250+
$protection = $client->api('repo')->protection()->replaceUserRestrictions('twbs', 'bootstrap', 'master', $params);
251+
```
252+
253+
### Add user restrictions of protected branch
254+
255+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
256+
257+
```php
258+
$params = [
259+
'octocat',
260+
];
261+
$protection = $client->api('repo')->protection()->addUserRestrictions('twbs', 'bootstrap', 'master', $params);
262+
```
263+
264+
### Remove user restrictions of protected branch
265+
266+
> Requires [authentication](../security.md) and is only available for organization-owned repositories.
267+
268+
```php
269+
$params = [
270+
'defunkt',
271+
];
272+
$protection = $client->api('repo')->protection()->removeUserRestrictions('twbs', 'bootstrap', 'master', $params);
273+
```

0 commit comments

Comments
 (0)