Repository navigation
Expand file tree
/
Copy pathRepository.php
More file actions
263 lines (230 loc) · 8.79 KB
/
Copy pathRepository.php
File metadata and controls
263 lines (230 loc) · 8.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?php declare(strict_types=1);
namespace ApiClients\Client\Github\Resource\Async;
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\AddLabelCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\AddWebHookCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\AppVeyorCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\BlobCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\CompareCommitsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileUploadCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\DetailedCommitCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\MilestonesCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\PullRequestsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\RefCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\RefsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\ReplaceTopicsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\ScrutinizerCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\TravisCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\TreeCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand;
use ApiClients\Client\Github\CommandBus\Command\Repository\UpdateSettingsCommand;
use ApiClients\Client\Github\CommandBus\Command\WebHooksCommand;
use ApiClients\Client\Github\Resource\Git\CommitInterface;
use ApiClients\Client\Github\Resource\Git\RefInterface;
use ApiClients\Client\Github\Resource\Git\TreeInterface;
use ApiClients\Client\Github\Resource\Repository as BaseRepository;
use ApiClients\Client\Github\VO\NamedBlob;
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
use React\Promise\PromiseInterface;
use React\Stream\ReadableStreamInterface;
use Rx\Observable;
use Rx\ObservableInterface;
class Repository extends BaseRepository
{
public function refresh(): PromiseInterface
{
return $this->handleCommand(
new RefreshCommand($this)
);
}
public function branches(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new BranchesCommand($this->fullName())
));
}
public function commits(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new CommitsCommand($this->fullName())
));
}
public function specificCommit(string $sha): PromiseInterface
{
return $this->handleCommand(
new DetailedCommitCommand(
$this->fullName(),
$sha
)
);
}
public function labels(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new LabelsCommand($this->fullName())
));
}
public function addLabel(string $name, string $colour): PromiseInterface
{
return $this->handleCommand(
new AddLabelCommand($this->fullName(), $name, $colour)
);
}
public function contents(string $path = '/'): Observable
{
return unwrapObservableFromPromise(
$this->handleCommand(
new ContentsCommand($this->fullName(), $path)
)
);
}
public function communityHealth(): PromiseInterface
{
return $this->handleCommand(
new CommunityHealthCommand($this->fullName())
);
}
public function tags(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new TagsCommand($this->fullName())
));
}
public function releases(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new ReleasesCommand($this->fullName())
));
}
public function languages(): PromiseInterface
{
return $this->handleCommand(
new LanguagesCommand($this->fullName())
);
}
public function webHooks(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new WebHooksCommand($this->fullName(), 'repos')
));
}
public function milestones(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new MilestonesCommand($this->fullName())
));
}
public function pullRequests(): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new PullRequestsCommand($this->fullName())
));
}
public function compareCommits(string $base, string $head): PromiseInterface
{
return $this->handleCommand(new CompareCommitsCommand($this, $base, $head));
}
public function addWebHook(
string $name,
array $config,
array $events,
bool $active
): PromiseInterface {
return $this->handleCommand(
new AddWebHookCommand(
$this->fullName(),
$name,
$config,
$events,
$active
)
);
}
public function addFile(
string $filename,
ReadableStreamInterface $stream,
string $commitMessage = '',
string $branch = ''
): PromiseInterface {
if ($commitMessage === '') {
$commitMessage = 'Update ' . $this->name;
}
return $this->handleCommand(new FileUploadCommand(
$this->full_name,
$commitMessage,
'/repos/' . $this->full_name . '/contents/' . $filename,
'',
$branch,
$stream
));
}
public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface
{
return $this->handleCommand(
new SubscribeCommand($this->fullName(), $subscribed, $ignored)
);
}
public function unSubscribe(): PromiseInterface
{
return $this->handleCommand(
new UnSubscribeCommand($this->fullName())
);
}
public function replaceTopics(string ...$topics): PromiseInterface
{
return $this->handleCommand(
new ReplaceTopicsCommand($this->fullName(), ...$topics)
);
}
public function travisRepository(): PromiseInterface
{
return $this->handleCommand(new TravisCommand($this->fullName()));
}
public function appVeyorRepository(): PromiseInterface
{
return $this->handleCommand(new AppVeyorCommand($this->fullName()));
}
public function scrutinizerRepository(): PromiseInterface
{
return $this->handleCommand(new ScrutinizerCommand(...\explode('/', $this->fullName())));
}
public function updateSettings(array $settings): PromiseInterface
{
if (!isset($settings['name'])) {
$settings['name'] = $this->name();
}
return $this->handleCommand(new UpdateSettingsCommand($this->fullName(), $settings));
}
public function blob(ReadableStreamInterface $contents): PromiseInterface
{
return $this->handleCommand(new BlobCommand($this->fullName(), $contents));
}
public function tree(?string $baseTree, NamedBlob ...$blobs): PromiseInterface
{
return $this->handleCommand(new TreeCommand($this->fullName(), $baseTree, ...$blobs));
}
public function commit(string $message, TreeInterface $tree, ?string ...$baseCommits): PromiseInterface
{
return $this->handleCommand(new CommitCommand($this->fullName(), $message, $tree->sha(), ...$baseCommits));
}
public function refs(?string $namespace = null): ObservableInterface
{
return unwrapObservableFromPromise($this->handleCommand(
new RefsCommand($this->fullName(), $namespace)
));
}
public function ref(RefInterface $ref, CommitInterface $tree): PromiseInterface
{
return $this->handleCommand(new RefCommand($this->fullName(), $ref->ref(), $tree->sha()));
}
}