| 1 | package Pithub::Repos; | ||||||||||||||
| 2 | 16 | our $AUTHORITY = 'cpan:PLU'; | |||||||||||||
| 3 | |||||||||||||||
| 4 | # ABSTRACT: Github v3 Repos API | ||||||||||||||
| 5 | |||||||||||||||
| 6 | 16 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 16 | our $VERSION = '0.01041'; | |||||||||||||
| 9 | |||||||||||||||
| 10 | 16 | ▶ | use Carp qw( croak ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 16 | ▶ | use Pithub::Issues (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 16 | ▶ | use Pithub::Markdown (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 16 | ▶ | use Pithub::PullRequests (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 16 | ▶ | use Pithub::Repos::Actions (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 16 | ▶ | use Pithub::Repos::Collaborators (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 16 | ▶ | use Pithub::Repos::Commits (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | 16 | ▶ | use Pithub::Repos::Contents (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | 16 | ▶ | use Pithub::Repos::Downloads (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 16 | ▶ | use Pithub::Repos::Forks (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | 16 | ▶ | use Pithub::Repos::Hooks (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | 16 | ▶ | use Pithub::Repos::Keys (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 22 | 16 | ▶ | use Pithub::Repos::Releases (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | 16 | ▶ | use Pithub::Repos::Starring (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | 16 | ▶ | use Pithub::Repos::Stats (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 25 | 16 | ▶ | use Pithub::Repos::Statuses (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | 16 | ▶ | use Pithub::Repos::Watching (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 16 | extends 'Pithub::Base'; | |||||||||||||
| 29 | |||||||||||||||
| 30 | |||||||||||||||
| 31 | sub actions { | ||||||||||||||
| 32 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Actions::, @_ ); | ||||||||||||
|
Subroutine
actions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | |||||||||||||||
| 36 | sub branch { | ||||||||||||||
| 37 | 3 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
branch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 38 | croak 'Missing key in parameters: branch (string)' | ||||||||||||||
| 39 | 3 | ▶ | unless defined $args{branch}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 2 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 41 | return $self->request( | ||||||||||||||
| 42 | method => 'GET', | ||||||||||||||
| 43 | path => sprintf( | ||||||||||||||
| 44 | '/repos/%s/%s/branches/%s', delete $args{user}, | ||||||||||||||
| 45 | delete $args{repo}, | ||||||||||||||
| 46 | delete $args{branch}, | ||||||||||||||
| 47 | 2 | ), | |||||||||||||
| 48 | %args, | ||||||||||||||
| 49 | ); | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | |||||||||||||||
| 53 | sub branches { | ||||||||||||||
| 54 | 9 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
branches: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 55 | 9 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 56 | return $self->request( | ||||||||||||||
| 57 | method => 'GET', | ||||||||||||||
| 58 | path => sprintf( | ||||||||||||||
| 59 | '/repos/%s/%s/branches', delete $args{user}, delete $args{repo} | ||||||||||||||
| 60 | 9 | ), | |||||||||||||
| 61 | %args, | ||||||||||||||
| 62 | ); | ||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | sub rename_branch { | ||||||||||||||
| 67 | 2 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
rename_branch: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||
| 68 | 2 | ▶ | croak 'Missing parameters: branch' unless $args{branch}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 69 | croak 'Missing key in parameters: data (hashref)' | ||||||||||||||
| 70 | 2 | ▶ | unless ref $args{data} eq 'HASH'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 71 | 2 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 72 | return $self->request( | ||||||||||||||
| 73 | method => 'POST', | ||||||||||||||
| 74 | path => sprintf( | ||||||||||||||
| 75 | '/repos/%s/%s/branches/%s/rename', delete $args{user}, | ||||||||||||||
| 76 | delete $args{repo}, delete $args{branch} | ||||||||||||||
| 77 | 2 | ), | |||||||||||||
| 78 | %args, | ||||||||||||||
| 79 | ); | ||||||||||||||
| 80 | } | ||||||||||||||
| 81 | |||||||||||||||
| 82 | |||||||||||||||
| 83 | sub merge_branch { | ||||||||||||||
| 84 | 2 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
merge_branch: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||
| 85 | croak 'Missing key in parameters: data (hashref)' | ||||||||||||||
| 86 | 2 | ▶ | unless ref $args{data} eq 'HASH'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 87 | 2 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 88 | return $self->request( | ||||||||||||||
| 89 | method => 'POST', | ||||||||||||||
| 90 | path => sprintf( | ||||||||||||||
| 91 | '/repos/%s/%s/merges', delete $args{user}, delete $args{repo} | ||||||||||||||
| 92 | 2 | ), | |||||||||||||
| 93 | %args, | ||||||||||||||
| 94 | ); | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | |||||||||||||||
| 98 | sub collaborators { | ||||||||||||||
| 99 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Collaborators::, @_ ); | ||||||||||||
|
Subroutine
collaborators: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 100 | } | ||||||||||||||
| 101 | |||||||||||||||
| 102 | |||||||||||||||
| 103 | sub commits { | ||||||||||||||
| 104 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Commits::, @_ ); | ||||||||||||
|
Subroutine
commits: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 105 | } | ||||||||||||||
| 106 | |||||||||||||||
| 107 | |||||||||||||||
| 108 | sub contents { | ||||||||||||||
| 109 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Contents::, @_ ); | ||||||||||||
|
Subroutine
contents: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 110 | } | ||||||||||||||
| 111 | |||||||||||||||
| 112 | |||||||||||||||
| 113 | sub contributors { | ||||||||||||||
| 114 | 9 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
contributors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 115 | 9 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 116 | return $self->request( | ||||||||||||||
| 117 | method => 'GET', | ||||||||||||||
| 118 | path => sprintf( | ||||||||||||||
| 119 | '/repos/%s/%s/contributors', delete $args{user}, | ||||||||||||||
| 120 | delete $args{repo} | ||||||||||||||
| 121 | 9 | ), | |||||||||||||
| 122 | %args, | ||||||||||||||
| 123 | ); | ||||||||||||||
| 124 | } | ||||||||||||||
| 125 | |||||||||||||||
| 126 | |||||||||||||||
| 127 | sub create { | ||||||||||||||
| 128 | 6 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
create: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 129 | croak 'Missing key in parameters: data (hashref)' | ||||||||||||||
| 130 | 6 | ▶ | unless ref $args{data} eq 'HASH'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 131 | 5 | ▶ | if ( my $org = delete $args{org} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 132 | 3 | return $self->request( | |||||||||||||
| 133 | method => 'POST', | ||||||||||||||
| 134 | path => sprintf( '/orgs/%s/repos', $org ), | ||||||||||||||
| 135 | %args, | ||||||||||||||
| 136 | ); | ||||||||||||||
| 137 | } | ||||||||||||||
| 138 | else { | ||||||||||||||
| 139 | 2 | return $self->request( | |||||||||||||
| 140 | method => 'POST', | ||||||||||||||
| 141 | path => '/user/repos', | ||||||||||||||
| 142 | %args, | ||||||||||||||
| 143 | ); | ||||||||||||||
| 144 | } | ||||||||||||||
| 145 | } | ||||||||||||||
| 146 | |||||||||||||||
| 147 | |||||||||||||||
| 148 | sub delete { | ||||||||||||||
| 149 | 4 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 150 | 4 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 151 | return $self->request( | ||||||||||||||
| 152 | method => 'DELETE', | ||||||||||||||
| 153 | path => | ||||||||||||||
| 154 | 2 | sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ), | |||||||||||||
| 155 | %args, | ||||||||||||||
| 156 | ); | ||||||||||||||
| 157 | } | ||||||||||||||
| 158 | |||||||||||||||
| 159 | |||||||||||||||
| 160 | sub downloads { | ||||||||||||||
| 161 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Downloads::, @_ ); | ||||||||||||
|
Subroutine
downloads: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 162 | } | ||||||||||||||
| 163 | |||||||||||||||
| 164 | |||||||||||||||
| 165 | sub forks { | ||||||||||||||
| 166 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Forks::, @_ ); | ||||||||||||
|
Subroutine
forks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 167 | } | ||||||||||||||
| 168 | |||||||||||||||
| 169 | |||||||||||||||
| 170 | sub get { | ||||||||||||||
| 171 | 2 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 172 | 2 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 173 | return $self->request( | ||||||||||||||
| 174 | method => 'GET', | ||||||||||||||
| 175 | path => | ||||||||||||||
| 176 | 2 | sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ), | |||||||||||||
| 177 | %args, | ||||||||||||||
| 178 | ); | ||||||||||||||
| 179 | } | ||||||||||||||
| 180 | |||||||||||||||
| 181 | |||||||||||||||
| 182 | sub hooks { | ||||||||||||||
| 183 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Hooks::, @_ ); | ||||||||||||
|
Subroutine
hooks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 184 | } | ||||||||||||||
| 185 | |||||||||||||||
| 186 | |||||||||||||||
| 187 | sub issues { | ||||||||||||||
| 188 | 1 | ▶ | return shift->_create_instance( Pithub::Issues::, @_ ); | ||||||||||||
|
Subroutine
issues: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 189 | } | ||||||||||||||
| 190 | |||||||||||||||
| 191 | |||||||||||||||
| 192 | sub keys { | ||||||||||||||
| 193 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Keys::, @_ ); | ||||||||||||
|
Subroutine
keys: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 194 | } | ||||||||||||||
| 195 | |||||||||||||||
| 196 | |||||||||||||||
| 197 | sub languages { | ||||||||||||||
| 198 | 9 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
languages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 199 | 9 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 200 | return $self->request( | ||||||||||||||
| 201 | method => 'GET', | ||||||||||||||
| 202 | path => sprintf( | ||||||||||||||
| 203 | '/repos/%s/%s/languages', delete $args{user}, delete $args{repo} | ||||||||||||||
| 204 | 9 | ), | |||||||||||||
| 205 | %args, | ||||||||||||||
| 206 | ); | ||||||||||||||
| 207 | } | ||||||||||||||
| 208 | |||||||||||||||
| 209 | |||||||||||||||
| 210 | sub list { | ||||||||||||||
| 211 | 5 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
list: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 212 | 5 | ▶ | if ( my $user = delete $args{user} ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 213 | 2 | return $self->request( | |||||||||||||
| 214 | method => 'GET', | ||||||||||||||
| 215 | path => sprintf( '/users/%s/repos', $user ), | ||||||||||||||
| 216 | %args, | ||||||||||||||
| 217 | ); | ||||||||||||||
| 218 | } | ||||||||||||||
| 219 | elsif ( my $org = delete $args{org} ) { | ||||||||||||||
| 220 | 1 | return $self->request( | |||||||||||||
| 221 | method => 'GET', | ||||||||||||||
| 222 | path => sprintf( '/orgs/%s/repos', $org ), | ||||||||||||||
| 223 | %args | ||||||||||||||
| 224 | ); | ||||||||||||||
| 225 | } | ||||||||||||||
| 226 | else { | ||||||||||||||
| 227 | 2 | return $self->request( | |||||||||||||
| 228 | method => 'GET', | ||||||||||||||
| 229 | path => '/user/repos', | ||||||||||||||
| 230 | %args, | ||||||||||||||
| 231 | ); | ||||||||||||||
| 232 | } | ||||||||||||||
| 233 | } | ||||||||||||||
| 234 | |||||||||||||||
| 235 | |||||||||||||||
| 236 | sub markdown { | ||||||||||||||
| 237 | 2 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
markdown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 238 | 2 | return $self->_create_instance( | |||||||||||||
| 239 | Pithub::Markdown::, | ||||||||||||||
| 240 | mode => 'gfm', | ||||||||||||||
| 241 | context => sprintf( '%s/%s', $self->user, $self->repo ), | ||||||||||||||
| 242 | @_ | ||||||||||||||
| 243 | ); | ||||||||||||||
| 244 | } | ||||||||||||||
| 245 | |||||||||||||||
| 246 | |||||||||||||||
| 247 | sub pull_requests { | ||||||||||||||
| 248 | 1 | ▶ | return shift->_create_instance( Pithub::PullRequests::, @_ ); | ||||||||||||
|
Subroutine
pull_requests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 249 | } | ||||||||||||||
| 250 | |||||||||||||||
| 251 | |||||||||||||||
| 252 | sub releases { | ||||||||||||||
| 253 | 3 | ▶ | return shift->_create_instance( Pithub::Repos::Releases::, @_ ); | ||||||||||||
|
Subroutine
releases: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 254 | } | ||||||||||||||
| 255 | |||||||||||||||
| 256 | |||||||||||||||
| 257 | sub starring { | ||||||||||||||
| 258 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Starring::, @_ ); | ||||||||||||
|
Subroutine
starring: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 259 | } | ||||||||||||||
| 260 | |||||||||||||||
| 261 | |||||||||||||||
| 262 | sub stats { | ||||||||||||||
| 263 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Stats::, @_ ); | ||||||||||||
|
Subroutine
stats: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 264 | } | ||||||||||||||
| 265 | |||||||||||||||
| 266 | |||||||||||||||
| 267 | sub statuses { | ||||||||||||||
| 268 | 1 | ▶ | return shift->_create_instance( Pithub::Repos::Statuses::, @_ ); | ||||||||||||
|
Subroutine
statuses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 269 | } | ||||||||||||||
| 270 | |||||||||||||||
| 271 | |||||||||||||||
| 272 | sub tags { | ||||||||||||||
| 273 | 9 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
tags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 274 | 9 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 275 | return $self->request( | ||||||||||||||
| 276 | method => 'GET', | ||||||||||||||
| 277 | path => sprintf( | ||||||||||||||
| 278 | '/repos/%s/%s/tags', delete $args{user}, delete $args{repo} | ||||||||||||||
| 279 | 9 | ), | |||||||||||||
| 280 | %args, | ||||||||||||||
| 281 | ); | ||||||||||||||
| 282 | } | ||||||||||||||
| 283 | |||||||||||||||
| 284 | |||||||||||||||
| 285 | sub teams { | ||||||||||||||
| 286 | 9 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
teams: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 287 | 9 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 288 | return $self->request( | ||||||||||||||
| 289 | method => 'GET', | ||||||||||||||
| 290 | path => sprintf( | ||||||||||||||
| 291 | '/repos/%s/%s/teams', delete $args{user}, delete $args{repo} | ||||||||||||||
| 292 | 9 | ), | |||||||||||||
| 293 | %args, | ||||||||||||||
| 294 | ); | ||||||||||||||
| 295 | } | ||||||||||||||
| 296 | |||||||||||||||
| 297 | |||||||||||||||
| 298 | sub update { | ||||||||||||||
| 299 | 4 | ▶ | my ( $self, %args ) = @_; | ||||||||||||
|
Subroutine
update: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 300 | croak 'Missing key in parameters: data (hashref)' | ||||||||||||||
| 301 | 4 | ▶ | unless ref $args{data} eq 'HASH'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 302 | 3 | $self->_validate_user_repo_args( \%args ); | |||||||||||||
| 303 | return $self->request( | ||||||||||||||
| 304 | method => 'PATCH', | ||||||||||||||
| 305 | path => | ||||||||||||||
| 306 | 3 | sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ), | |||||||||||||
| 307 | %args, | ||||||||||||||
| 308 | ); | ||||||||||||||
| 309 | } | ||||||||||||||
| 310 | |||||||||||||||
| 311 | |||||||||||||||
| 312 | sub watching { | ||||||||||||||
| 313 | 13 | ▶ | return shift->_create_instance( Pithub::Repos::Watching::, @_ ); | ||||||||||||
|
Subroutine
watching: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 314 | } | ||||||||||||||
| 315 | |||||||||||||||
| 316 | 16 | 1; | |||||||||||||
| 317 | |||||||||||||||
| 318 | __END__ | ||||||||||||||