.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::GitHub::V3::Repos 3pm" .TH Net::GitHub::V3::Repos 3pm "2022-10-08" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::GitHub::V3::Repos \- GitHub Repos API .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::GitHub::V3; \& \& my $gh = Net::GitHub::V3\->new; # read L to set right authentication info \& my $repos = $gh\->repos; \& \& # set :user/:repo for simple calls \& $repos\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); \& my @contributors = $repos\->contributors; # don\*(Aqt need pass user and repos .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" .SS "\s-1METHODS\s0" .IX Subsection "METHODS" \fIRepos\fR .IX Subsection "Repos" .PP .IP "list" 4 .IX Item "list" .PD 0 .IP "list_all" 4 .IX Item "list_all" .PD .Vb 4 \& # All public repositories on Github \& my @rp = $repos\->list_all; \& # starting at id 500 \& my @rp = $repos\->list_all(500); .Ve .IP "list_user" 4 .IX Item "list_user" .PD 0 .IP "list_org" 4 .IX Item "list_org" .PD .Vb 11 \& my @rp = $repos\->list; # or my $rp = $repos\->list; \& my @rp = $repos\->list({ \& type => \*(Aqprivate\*(Aq \& sort => \*(Aqupdated\*(Aq \& }); \& my @rp = $repos\->list_user(\*(Aqc9s\*(Aq); \& my @rp = $repos\->list_user(\*(Aqc9s\*(Aq, { \& type => \*(Aqmember\*(Aq \& }); \& my @rp = $repos\->list_org(\*(Aqperlchina\*(Aq); \& my @rp = $repos\->list_org(\*(Aqperlchina\*(Aq, \*(Aqpublic\*(Aq); .Ve .IP "next_repo, next_all_repo, next_user_repo, next_org_repo" 4 .IX Item "next_repo, next_all_repo, next_user_repo, next_org_repo" .Vb 8 \& # Iterate over your repositories \& while (my $repo = $repos\->next_repo) { ...; } \& # Iterate over all public repositories \& while (my $repo = $repos\->next_all_repo(500)) { ...; } \& # Iterate over repositories of another user \& while (my $repo = $repos\->next_user_repo(\*(Aqc9s\*(Aq)) { ...; } \& # Iterate over repositories of an organisation \& while (my $repo = $repos\->next_org_repo(\*(Aqperlchina\*(Aq,\*(Aqpublic\*(Aq)) { ...; } .Ve .IP "create" 4 .IX Item "create" .Vb 10 \& # create for yourself \& my $rp = $repos\->create( { \& "name" => "Hello\-World", \& "description" => "This is your first repo", \& "homepage" => "https://github.com" \& } ); \& # create for organization \& my $rp = $repos\->create( { \& "org" => "perlchina", ## the organization \& "name" => "Hello\-World", \& "description" => "This is your first repo", \& "homepage" => "https://github.com" \& } ); .Ve .IP "get" 4 .IX Item "get" .Vb 1 \& my $rp = $repos\->get(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); .Ve .PP \&\fBTo ease the keyboard, we provied two ways to call any method which starts with :user/:repo\fR .PP 1. \s-1SET\s0 user/repos before call methods below .PP .Vb 3 \& $gh\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); # take effects for all $gh\-> \& $repos\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); # only take effect to $gh\->repos \& my @contributors = $repos\->contributors; .Ve .PP 2. If it is just for once, we can pass :user, :repo before any arguments .PP .Vb 1 \& my @contributors = $repos\->contributors($user, $repo); .Ve .IP "update" 4 .IX Item "update" .Vb 1 \& $repos\->update({ homepage => \*(Aqhttps://metacpan.org/module/Net::GitHub\*(Aq }); .Ve .IP "delete" 4 .IX Item "delete" .Vb 1 \& $repos\->delete(); .Ve .IP "contributors" 4 .IX Item "contributors" .PD 0 .IP "languages" 4 .IX Item "languages" .IP "teams" 4 .IX Item "teams" .IP "tags" 4 .IX Item "tags" .IP "contributors" 4 .IX Item "contributors" .PD .Vb 9 \& my @contributors = $repos\->contributors; \& my @languages = $repos\->languages; \& my @teams = $repos\->teams; \& my @tags = $repos\->tags; \& my @branches = $repos\->branches; \& my $branch = $repos\->branch(\*(Aqmaster\*(Aq); \& while (my $contributor = $repos\->next_contributor) { ...; } \& while (my $team = $repos\->next_team) { ... ; } \& while (my $tags = $repos\->next_tag) { ... ; } .Ve .PP \fIRepo Collaborators \s-1API\s0\fR .IX Subsection "Repo Collaborators API" .PP .IP "collaborators" 4 .IX Item "collaborators" .PD 0 .IP "is_collaborator" 4 .IX Item "is_collaborator" .IP "add_collaborator" 4 .IX Item "add_collaborator" .IP "delete_collaborator" 4 .IX Item "delete_collaborator" .PD .Vb 5 \& my @collaborators = $repos\->collaborators; \& while (my $collaborator = $repos\->next_collaborator) { ...; } \& my $is = $repos\->is_collaborator(\*(Aqfayland\*(Aq); \& $repos\->add_collaborator(\*(Aqfayland\*(Aq); \& $repos\->delete_collaborator(\*(Aqfayland\*(Aq); .Ve .PP \fICommits \s-1API\s0\fR .IX Subsection "Commits API" .PP .IP "commits" 4 .IX Item "commits" .PD 0 .IP "commit" 4 .IX Item "commit" .PD .Vb 6 \& my @commits = $repos\->commits; \& my @commits = $repos\->commits({ \& author => \*(Aqfayland\*(Aq \& }); \& my $commit = $repos\->commit($sha); \& while (my $commit = $repos\->next_commit({...})) { ...; } .Ve .IP "comments" 4 .IX Item "comments" .PD 0 .IP "commit_comments" 4 .IX Item "commit_comments" .IP "create_comment" 4 .IX Item "create_comment" .IP "comment" 4 .IX Item "comment" .IP "update_comment" 4 .IX Item "update_comment" .IP "delete_comment" 4 .IX Item "delete_comment" .PD .Vb 10 \& my @comments = $repos\->comments; \& while (my $comment = $repos\->next_comment) { ...; } \& my @comments = $repos\->commit_comments($sha); \& while (my $comment = $repos\->next_commit_comment($sha)) { ...; } \& my $comment = $repos\->create_comment($sha, { \& "body" => "Nice change", \& "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e", \& "line" => 1, \& "path" => "file1.txt", \& "position" => 4 \& }); \& my $comment = $repos\->comment($comment_id); \& my $comment = $repos\->update_comment($comment_id, { \& "body" => "Nice change" \& }); \& my $st = $repos\->delete_comment($comment_id); .Ve .IP "compare_commits" 4 .IX Item "compare_commits" .Vb 1 \& my $diffs = $repos\->compare_commits($base, $head); .Ve .PP \fIForks \s-1API\s0\fR .IX Subsection "Forks API" .PP .IP "forks" 4 .IX Item "forks" .PD 0 .IP "create_fork" 4 .IX Item "create_fork" .PD .Vb 4 \& my @forks = $repos\->forks; \& while (my $fork = $repos\->next_fork) { ...; } \& my $fork = $repos\->create_fork; \& my $fork = $repos\->create_fork($org); .Ve .PP \fIRepos Deploy Keys \s-1API\s0\fR .IX Subsection "Repos Deploy Keys API" .PP .IP "keys" 4 .IX Item "keys" .PD 0 .IP "key" 4 .IX Item "key" .IP "create_key" 4 .IX Item "create_key" .IP "update_key" 4 .IX Item "update_key" .IP "delete_key" 4 .IX Item "delete_key" .PD .Vb 12 \& my @keys = $repos\->keys; \& while (my $key = $repos\->next_key) { ...; } \& my $key = $repos\->key($key_id); # get key \& $repos\->create_key( { \& title => \*(Aqtitle\*(Aq, \& key => $key \& } ); \& $repos\->update_key($key_id, { \& title => $title, \& key => $key \& }); \& $repos\->delete_key($key_id); .Ve .PP \fIRepo Watching \s-1API\s0\fR .IX Subsection "Repo Watching API" .PP .IP "watchers" 4 .IX Item "watchers" .Vb 2 \& my @watchers = $repos\->watchers; \& while (my $watcher = $repos\->next_watcher) { ...; } .Ve .IP "watched" 4 .IX Item "watched" .Vb 2 \& my @repos = $repos\->watched; # what I watched \& my @repos = $repos\->watched(\*(Aqc9s\*(Aq); .Ve .IP "is_watching" 4 .IX Item "is_watching" .Vb 2 \& my $is_watching = $repos\->is_watching; \& my $is_watching = $repos\->is_watching(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); .Ve .IP "watch" 4 .IX Item "watch" .PD 0 .IP "unwatch" 4 .IX Item "unwatch" .PD .Vb 4 \& my $st = $repos\->watch(); \& my $st = $repos\->watch(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); \& my $st = $repos\->unwatch(); \& my $st = $repos\->unwatch(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); .Ve .PP \fISubscriptions\fR .IX Subsection "Subscriptions" .PP Github changed the ideas of Watchers (stars) and Subscriptions (new watchers). .PP .Vb 1 \& https://github.com/blog/1204\-notifications\-stars .Ve .PP The Watchers code in this module predates the terminology change, so the new Watcher methods use the GitHub 'subscription' terminology. .IP "subscribers" 4 .IX Item "subscribers" Returns a list of subscriber data hashes. .IP "next_subscriber" 4 .IX Item "next_subscriber" Returns the next subscriber in the list, or undef if there are no more subscribers. .IP "is_subscribed" 4 .IX Item "is_subscribed" Returns true or false if you are subscribed .Sp .Vb 2 \& $repos\->is_subscribed(); \& $repos\->is_subscribed(\*(Aqfayland\*(Aq,\*(Aqperl\-net\-github\*(Aq); .Ve .IP "subscription" 4 .IX Item "subscription" Returns more information about your subscription to a repo. is_subscribed is a shortcut to calling this and checking for subscribed => 1. .IP "subscribe" 4 .IX Item "subscribe" Required argument telling github if you want to subscribe or if you want to ignore mentions. If you want to change from subscribed to ignores you need to unsubscribe first. .Sp .Vb 2 \& $repos\->subscribe(\*(Aqfayland\*(Aq,\*(Aqperl\-net\-github\*(Aq, { subscribed => 1 }) \& $repos\->subscribe(\*(Aqfayland\*(Aq,\*(Aqperl\-net\-github\*(Aq, { ignored => 1 }) .Ve .IP "unsubscribe" 4 .IX Item "unsubscribe" .Vb 1 \& $repos\->unsubscribe(\*(Aqfayland\*(Aq,\*(Aqperl\-net\-github\*(Aq); .Ve .PP \fIHooks \s-1API\s0\fR .IX Subsection "Hooks API" .PP .IP "hooks" 4 .IX Item "hooks" .PD 0 .IP "next_hook" 4 .IX Item "next_hook" .IP "hook" 4 .IX Item "hook" .IP "create_hook" 4 .IX Item "create_hook" .IP "update_hook" 4 .IX Item "update_hook" .IP "test_hook" 4 .IX Item "test_hook" .IP "delete_hook" 4 .IX Item "delete_hook" .PD .Vb 7 \& my @hooks = $repos\->hooks; \& while (my $hook = $repos\->next_hook) { ...; } \& my $hook = $repos\->hook($hook_id); \& my $hook = $repos\->create_hook($hook_hash); \& my $hook = $repos\->update_hook($hook_id, $new_hook_hash); \& my $st = $repos\->test_hook($hook_id); \& my $st = $repos\->delete_hook($hook_id); .Ve .PP \fIRepo Merging \s-1API\s0\fR .IX Subsection "Repo Merging API" .PP .IP "merges" 4 .IX Item "merges" .Vb 5 \& my $status = $repos\->merges( { \& "base" => "master", \& "head" => "cool_feature", \& "commit_message" => "Shipped cool_feature!" \& } ); .Ve .PP \fIRepo Statuses \s-1API\s0\fR .IX Subsection "Repo Statuses API" .PP .IP "list_statuses" 4 .IX Item "list_statuses" .Vb 2 \& $gh\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); \& my @statuses = $repos\->lists_statuses($sha); .Ve .Sp Or: .Sp .Vb 1 \& my @statuses = $repos\->list_statuses(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq, $sha); .Ve .IP "next_status" 4 .IX Item "next_status" .Vb 1 \& while (my $status = $repos\->next_status($sha)) { ...; } .Ve .IP "create_status" 4 .IX Item "create_status" .Vb 8 \& $gh\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); \& my %payload = { \& "state" => "success", \& "target_url" => "https://example.com/build/status", \& "description" => "The build succeeded!", \& "context" => "build/status" \& }; \& my $status = $repos\->create_status($sha, %payload); .Ve .Sp Or: .Sp .Vb 9 \& my %payload = { \& "state" => "success", \& "target_url" => "https://example.com/build/status", \& "description" => "The build succeeded!", \& "context" => "build/status" \& }; \& my $status = $repos\->create_status( \& \*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq, $sha, %payload \& ); .Ve .PP \fIRepo Releases \s-1API\s0\fR .IX Subsection "Repo Releases API" .PP .IP "releases" 4 .IX Item "releases" .Vb 2 \& my @releases = $repos\->releases(); \& while (my $release = $repos\->next_release) { ...; } .Ve .IP "release" 4 .IX Item "release" .Vb 1 \& my $release = $repos\->release($release_id); .Ve .IP "create_release" 4 .IX Item "create_release" .Vb 7 \& my $release = $repos\->create_release({ \& "tag_name" => "v1.0.0", \& "target_commitish" => "master", \& "name" => "v1.0.0", \& "body" => "Description of the release", \& "draft" => \e1, \& }); .Ve .IP "update_release" 4 .IX Item "update_release" .Vb 6 \& my $release = $repos\->update_release($release_id, { \& "tag_name" => "v1.0.0", \& "target_commitish" => "master", \& "name" => "v1.0.0", \& "body" => "Description of the release", \& }); .Ve .IP "delete_release" 4 .IX Item "delete_release" .Vb 1 \& $repos\->delete_release($release_id); .Ve .IP "release_assets" 4 .IX Item "release_assets" .Vb 2 \& my @release_assets = $repos\->release_assets($release_id); \& while (my $asset = $repos\->next_release_asset($release_id)) { ...; } .Ve .IP "upload_asset" 4 .IX Item "upload_asset" .Vb 1 \& my $asset = $repos\->upload_asset($release_id, $name, $content_type, $file_content); .Ve .Sp Check examples/upload_asset.pl for a working example. .IP "release_asset" 4 .IX Item "release_asset" .Vb 1 \& my $release_asset = $repos\->release_asset($release_id, $asset_id); .Ve .IP "update_release_asset" 4 .IX Item "update_release_asset" .Vb 4 \& my $release_asset = $repos\->update_release_asset($release_id, $asset_id, { \& name" => "foo\-1.0.0\-osx.zip", \& "label" => "Mac binary" \& }); .Ve .IP "delete_release_asset" 4 .IX Item "delete_release_asset" .Vb 1 \& my $ok = $repos\->delete_release_asset($release_id, $asset_id); .Ve .PP \fIContents \s-1API\s0\fR .IX Subsection "Contents API" .PP .IP "get_content" 4 .IX Item "get_content" Gets the contents of a file or directory in a repository. Specify the file path or directory in \f(CW$path\fR. If you omit \f(CW$path\fR, you will receive the contents of all files in the repository. .Sp .Vb 10 \& my $response = $repos\->get_content( $owner, $repo, $path ) \& or \& $repos\->get_content( \& { owner => $owner, repo => $repo, path => $path }, \& ) \& or \& $repos\->get_content( \& { owner => $owner, repo => $repo, path => $path }, \& { ref => \*(Aqfeature\-branch\*(Aq } \& ) .Ve .PP \fIRepo Deployment \s-1API\s0\fR .IX Subsection "Repo Deployment API" .PP .IP "list_deployments" 4 .IX Item "list_deployments" .Vb 3 \& my $response = $repos\->list_deployments( $owner, $repo, { \& \*(Aqref\*(Aq => \*(Aqfeature\-branch\*(Aq, \& }); .Ve .IP "next_deployment" 4 .IX Item "next_deployment" .Vb 3 \& while (my $deployment = $repos\->next_deployment( $owner, $repo, { \& \*(Aqref\*(Aq => \*(Aqfeature\-branch\*(Aq, \& }) { ...; } .Ve .IP "create_deployment" 4 .IX Item "create_deployment" .Vb 4 \& my $response = $repos\->create_deployment( $owner, $repo, { \& "ref" => \*(Aqfeature\-branch\*(Aq, \& "description" => "deploying my new feature", \& }); .Ve .IP "list_deployment_statuses" 4 .IX Item "list_deployment_statuses" .Vb 1 \& my $response = $repos\->list_deployment_statuses( $owner, $repo, $deployment_id ); .Ve .IP "next_deployment_status" 4 .IX Item "next_deployment_status" .Vb 1 \& while (my $status = next_deployment_status($o,$r,$id)) { ...; } .Ve .IP "create_deployment_status" 4 .IX Item "create_deployment_status" .Vb 5 \& my $response = $repos\->create_deployment_status( $owner, $repo, $deployment_id, { \& "state": "success", \& "target_url": "https://example.com/deployment/42/output", \& "description": "Deployment finished successfully." \& }); .Ve .PP \fIRepo Statistics \s-1API\s0\fR .IX Subsection "Repo Statistics API" .PP .IP "contributor stats" 4 .IX Item "contributor stats" .PD 0 .IP "commit activity" 4 .IX Item "commit activity" .IP "code frequency" 4 .IX Item "code frequency" .IP "participation" 4 .IX Item "participation" .IP "punch card" 4 .IX Item "punch card" .PD .Vb 5 \& my $contributor_stats = $repos\->contributor_stats($owner, $repo); \& my $commit_activity = $repos\->commit_activity($owner, $repo); \& my $code_freq = $repos\->code_frequency($owner, $repo); \& my $participation = $repos\->participation($owner, $repo); \& my $punch_card = $repos\->punch_card($owner, $repo); .Ve .PP \fIBranch Protection \s-1API\s0\fR .IX Subsection "Branch Protection API" .PP .IP "branch_protection" 4 .IX Item "branch_protection" .Vb 1 \& my $protection = $repos\->branch_protection(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq, \*(Aqmaster\*(Aq); .Ve .IP "delete_branch_protection" 4 .IX Item "delete_branch_protection" .Vb 1 \& $repos\->delete_branch_protection(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq, \*(Aqmaster\*(Aq); .Ve .IP "update_branch_protection" 4 .IX Item "update_branch_protection" .Vb 10 \& $repos\->update_branch_protection(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq, \*(Aqmaster\*(Aq, { \& allow_deletions => \e0, \& allow_force_pushes => \e0, \& block_creations => \e1, \& enforce_admins => \e1, \& required_conversation_resolution => \e1, \& required_linear_history => \e0, \& required_pull_request_reviews => { \& dismiss_stale_reviews => \e1, \& require_code_owner_reviews => \e1, \& required_approving_review_count => 2, \& }, \& required_status_checks => { \& strict => \e1, \& contexts => [] \& }, \& restrictions => undef, \& }); .Ve .SH "AUTHOR & COPYRIGHT & LICENSE" .IX Header "AUTHOR & COPYRIGHT & LICENSE" Refer Net::GitHub