1Net::GitHub::V3::Repos(U3s)er Contributed Perl DocumentatNieotn::GitHub::V3::Repos(3)
2
3
4
6 Net::GitHub::V3::Repos - GitHub Repos API
7
9 use Net::GitHub::V3;
10
11 my $gh = Net::GitHub::V3->new; # read L<Net::GitHub::V3> to set right authentication info
12 my $repos = $gh->repos;
13
14 # set :user/:repo for simple calls
15 $repos->set_default_user_repo('fayland', 'perl-net-github');
16 my @contributors = $repos->contributors; # don't need pass user and repos
17
19 METHODS
20 Repos
21
22 <http://developer.github.com/v3/repos/>
23
24 list
25 list_all
26 # All public repositories on Github
27 my @rp = $repos->list_all;
28 # starting at id 500
29 my @rp = $repos->list_all(500);
30
31 list_user
32 list_org
33 my @rp = $repos->list; # or my $rp = $repos->list;
34 my @rp = $repos->list({
35 type => 'private'
36 sort => 'updated'
37 });
38 my @rp = $repos->list_user('c9s');
39 my @rp = $repos->list_user('c9s', {
40 type => 'member'
41 });
42 my @rp = $repos->list_org('perlchina');
43 my @rp = $repos->list_org('perlchina', 'public');
44
45 next_repo, next_all_repo, next_user_repo, next_org_repo
46 # Iterate over your repositories
47 while (my $repo = $repos->next_repo) { ...; }
48 # Iterate over all public repositories
49 while (my $repo = $repos->next_all_repo(500)) { ...; }
50 # Iterate over repositories of another user
51 while (my $repo = $repos->next_user_repo('c9s')) { ...; }
52 # Iterate over repositories of an organisation
53 while (my $repo = $repos->next_org_repo('perlchina','public')) { ...; }
54
55 create
56 # create for yourself
57 my $rp = $repos->create( {
58 "name" => "Hello-World",
59 "description" => "This is your first repo",
60 "homepage" => "https://github.com"
61 } );
62 # create for organization
63 my $rp = $repos->create( {
64 "org" => "perlchina", ## the organization
65 "name" => "Hello-World",
66 "description" => "This is your first repo",
67 "homepage" => "https://github.com"
68 } );
69
70 get
71 my $rp = $repos->get('fayland', 'perl-net-github');
72
73 To ease the keyboard, we provied two ways to call any method which
74 starts with :user/:repo
75
76 1. SET user/repos before call methods below
77
78 $gh->set_default_user_repo('fayland', 'perl-net-github'); # take effects for all $gh->
79 $repos->set_default_user_repo('fayland', 'perl-net-github'); # only take effect to $gh->repos
80 my @contributors = $repos->contributors;
81
82 2. If it is just for once, we can pass :user, :repo before any
83 arguments
84
85 my @contributors = $repos->contributors($user, $repo);
86
87 update
88 $repos->update({ homepage => 'https://metacpan.org/module/Net::GitHub' });
89
90 delete
91 $repos->delete();
92
93 contributors
94 languages
95 teams
96 tags
97 contributors
98 my @contributors = $repos->contributors;
99 my @languages = $repos->languages;
100 my @teams = $repos->teams;
101 my @tags = $repos->tags;
102 my @branches = $repos->branches;
103 my $branch = $repos->branch('master');
104 while (my $contributor = $repos->next_contributor) { ...; }
105 while (my $team = $repos->next_team) { ... ; }
106 while (my $tags = $repos->next_tag) { ... ; }
107
108 Repo Collaborators API
109
110 <http://developer.github.com/v3/repos/collaborators/>
111
112 collaborators
113 is_collaborator
114 add_collaborator
115 delete_collaborator
116 my @collaborators = $repos->collaborators;
117 while (my $collaborator = $repos->next_collaborator) { ...; }
118 my $is = $repos->is_collaborator('fayland');
119 $repos->add_collaborator('fayland');
120 $repos->delete_collaborator('fayland');
121
122 Commits API
123
124 <http://developer.github.com/v3/repos/commits/>
125
126 commits
127 commit
128 my @commits = $repos->commits;
129 my @commits = $repos->commits({
130 author => 'fayland'
131 });
132 my $commit = $repos->commit($sha);
133 while (my $commit = $repos->next_commit({...})) { ...; }
134
135 comments
136 commit_comments
137 create_comment
138 comment
139 update_comment
140 delete_comment
141 my @comments = $repos->comments;
142 while (my $comment = $repos->next_comment) { ...; }
143 my @comments = $repos->commit_comments($sha);
144 while (my $comment = $repos->next_commit_comment($sha)) { ...; }
145 my $comment = $repos->create_comment($sha, {
146 "body" => "Nice change",
147 "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
148 "line" => 1,
149 "path" => "file1.txt",
150 "position" => 4
151 });
152 my $comment = $repos->comment($comment_id);
153 my $comment = $repos->update_comment($comment_id, {
154 "body" => "Nice change"
155 });
156 my $st = $repos->delete_comment($comment_id);
157
158 compare_commits
159 my $diffs = $repos->compare_commits($base, $head);
160
161 Forks API
162
163 <http://developer.github.com/v3/repos/forks/>
164
165 forks
166 create_fork
167 my @forks = $repos->forks;
168 while (my $fork = $repos->next_fork) { ...; }
169 my $fork = $repos->create_fork;
170 my $fork = $repos->create_fork($org);
171
172 Repos Deploy Keys API
173
174 <http://developer.github.com/v3/repos/keys/>
175
176 keys
177 key
178 create_key
179 update_key
180 delete_key
181 my @keys = $repos->keys;
182 while (my $key = $repos->next_key) { ...; }
183 my $key = $repos->key($key_id); # get key
184 $repos->create_key( {
185 title => 'title',
186 key => $key
187 } );
188 $repos->update_key($key_id, {
189 title => $title,
190 key => $key
191 });
192 $repos->delete_key($key_id);
193
194 Repo Watching API
195
196 <http://developer.github.com/v3/repos/watching/>
197
198 watchers
199 my @watchers = $repos->watchers;
200 while (my $watcher = $repos->next_watcher) { ...; }
201
202 watched
203 my @repos = $repos->watched; # what I watched
204 my @repos = $repos->watched('c9s');
205
206 is_watching
207 my $is_watching = $repos->is_watching;
208 my $is_watching = $repos->is_watching('fayland', 'perl-net-github');
209
210 watch
211 unwatch
212 my $st = $repos->watch();
213 my $st = $repos->watch('fayland', 'perl-net-github');
214 my $st = $repos->unwatch();
215 my $st = $repos->unwatch('fayland', 'perl-net-github');
216
217 Subscriptions
218
219 Github changed the ideas of Watchers (stars) and Subscriptions (new
220 watchers).
221
222 https://github.com/blog/1204-notifications-stars
223
224 The Watchers code in this module predates the terminology change, so
225 the new Watcher methods use the GitHub 'subscription' terminology.
226
227 subscribers
228 Returns a list of subscriber data hashes.
229
230 next_subscriber
231 Returns the next subscriber in the list, or undef if there are no
232 more subscribers.
233
234 is_subscribed
235 Returns true or false if you are subscribed
236
237 $repos->is_subscribed();
238 $repos->is_subscribed('fayland','perl-net-github');
239
240 subscription
241 Returns more information about your subscription to a repo.
242 is_subscribed is a shortcut to calling this and checking for
243 subscribed => 1.
244
245 subscribe
246 Required argument telling github if you want to subscribe or if you
247 want to ignore mentions. If you want to change from subscribed to
248 ignores you need to unsubscribe first.
249
250 $repos->subscribe('fayland','perl-net-github', { subscribed => 1 })
251 $repos->subscribe('fayland','perl-net-github', { ignored => 1 })
252
253 unsubscribe
254 $repos->unsubscribe('fayland','perl-net-github');
255
256 Hooks API
257
258 <http://developer.github.com/v3/repos/hooks/>
259
260 hooks
261 next_hook
262 hook
263 create_hook
264 update_hook
265 test_hook
266 delete_hook
267 my @hooks = $repos->hooks;
268 while (my $hook = $repos->next_hook) { ...; }
269 my $hook = $repos->hook($hook_id);
270 my $hook = $repos->create_hook($hook_hash);
271 my $hook = $repos->update_hook($hook_id, $new_hook_hash);
272 my $st = $repos->test_hook($hook_id);
273 my $st = $repos->delete_hook($hook_id);
274
275 Repo Merging API
276
277 <http://developer.github.com/v3/repos/merging/>
278
279 merges
280 my $status = $repos->merges( {
281 "base" => "master",
282 "head" => "cool_feature",
283 "commit_message" => "Shipped cool_feature!"
284 } );
285
286 Repo Statuses API
287
288 <http://developer.github.com/v3/repos/statuses/>
289
290 list_statuses
291 $gh->set_default_user_repo('fayland', 'perl-net-github');
292 my @statuses = $repos->lists_statuses($sha);
293
294 Or:
295
296 my @statuses = $repos->list_statuses('fayland', 'perl-net-github', $sha);
297
298 next_status
299 while (my $status = $repos->next_status($sha)) { ...; }
300
301 create_status
302 $gh->set_default_user_repo('fayland', 'perl-net-github');
303 my %payload = {
304 "state" => "success",
305 "target_url" => "https://example.com/build/status",
306 "description" => "The build succeeded!",
307 "context" => "build/status"
308 };
309 my $status = $repos->create_status($sha, %payload);
310
311 Or:
312
313 my %payload = {
314 "state" => "success",
315 "target_url" => "https://example.com/build/status",
316 "description" => "The build succeeded!",
317 "context" => "build/status"
318 };
319 my $status = $repos->create_status(
320 'fayland', 'perl-net-github', $sha, %payload
321 );
322
323 Repo Releases API
324
325 <http://developer.github.com/v3/repos/releases/>
326
327 releases
328 my @releases = $repos->releases();
329 while (my $release = $repos->next_release) { ...; }
330
331 release
332 my $release = $repos->release($release_id);
333
334 create_release
335 my $release = $repos->create_release({
336 "tag_name" => "v1.0.0",
337 "target_commitish" => "master",
338 "name" => "v1.0.0",
339 "body" => "Description of the release",
340 "draft" => \1,
341 });
342
343 update_release
344 my $release = $repos->update_release($release_id, {
345 "tag_name" => "v1.0.0",
346 "target_commitish" => "master",
347 "name" => "v1.0.0",
348 "body" => "Description of the release",
349 });
350
351 delete_release
352 $repos->delete_release($release_id);
353
354 release_assets
355 my @release_assets = $repos->release_assets($release_id);
356 while (my $asset = $repos->next_release_asset($release_id)) { ...; }
357
358 upload_asset
359 my $asset = $repos->upload_asset($release_id, $name, $content_type, $file_content);
360
361 Check examples/upload_asset.pl for a working example.
362
363 release_asset
364 my $release_asset = $repos->release_asset($release_id, $asset_id);
365
366 update_release_asset
367 my $release_asset = $repos->update_release_asset($release_id, $asset_id, {
368 name" => "foo-1.0.0-osx.zip",
369 "label" => "Mac binary"
370 });
371
372 delete_release_asset
373 my $ok = $repos->delete_release_asset($release_id, $asset_id);
374
375 Repo Deployment API
376
377 <http://developer.github.com/v3/repos/deployments/>
378
379 list_deployments
380 my $response = $repos->list_deployments( $owner, $repo, {
381 'ref' => 'feature-branch',
382 });
383
384 next_deployment
385 while (my $deployment = $repos->next_deployment( $owner, $repo, {
386 'ref' => 'feature-branch',
387 }) { ...; }
388
389 create_deployment
390 my $response = $repos->create_deployment( $owner, $repo, {
391 "ref" => 'feature-branch',
392 "description" => "deploying my new feature",
393 });
394
395 list_deployment_statuses
396 my $response = $repos->list_deployment_statuses( $owner, $repo, $deployment_id );
397
398 next_deployment_status
399 while (my $status = next_deployment_status($o,$r,$id)) { ...; }
400
401 create_deployment_status
402 my $response = $repos->create_deployment_status( $owner, $repo, $deployment_id, {
403 "state": "success",
404 "target_url": "https://example.com/deployment/42/output",
405 "description": "Deployment finished successfully."
406 });
407
408 Repo Statistics API
409
410 <http://developer.github.com/v3/repos/statistics/>
411
412 contributor stats
413 commit activity
414 code frequency
415 participation
416 punch card
417 my $contributor_stats = $repos->contributor_stats($owner, $repo);
418 my $commit_activity = $repos->commit_activity($owner, $repo);
419 my $code_freq = $repos->code_frequency($owner, $repo);
420 my $participation = $repos->participation($owner, $repo);
421 my $punch_card = $repos->punch_card($owner, $repo);
422
424 Refer Net::GitHub
425
426
427
428perl v5.28.0 2018-03-30 Net::GitHub::V3::Repos(3)