| 1 | package GitHub::EmptyRepository::Repository::Commit; | ||
| 2 | use Moo; | ||
| 3 | |||
| 4 | our $VERSION = '0.00002'; | ||
| 5 | |||
| 6 | use MooX::StrictConstructor; | ||
| 7 | use Types::Standard qw( ArrayRef Bool Int InstanceOf Str ); | ||
| 8 | use Pithub::Repos::Commits (); | ||
| 9 | |||
| 10 | has github_client => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => InstanceOf ['Pithub::Repos::Commits'], | ||
| 13 | required => 1, | ||
| 14 | ); | ||
| 15 | |||
| 16 | has user => ( | ||
| 17 | is => 'ro', | ||
| 18 | isa => Str, | ||
| 19 | ); | ||
| 20 | |||
| 21 | has repo => ( | ||
| 22 | is => 'ro', | ||
| 23 | isa => Str, | ||
| 24 | ); | ||
| 25 | |||
| 26 | has sha => ( | ||
| 27 | is => 'ro', | ||
| 28 | isa => Str, | ||
| 29 | ); | ||
| 30 | |||
| 31 | has files => ( | ||
| 32 | is => 'ro', | ||
| 33 | isa => ArrayRef, | ||
| 34 | lazy => 1, | ||
| 35 | builder => '_get_files', | ||
| 36 | ); | ||
| 37 | |||
| 38 | sub _get_files { | ||
| 39 | my $self = shift; | ||
| 40 | |||
| 41 | my $result = $self->github_client->get( | ||
| 42 | user => $self->user, | ||
| 43 | repo => $self->repo, | ||
| 44 | sha => $self->sha, | ||
| 45 | ); | ||
| 46 | |||
| 47 | return [] unless $result->response->is_success; | ||
| 48 | |||
| 49 | my @committed_files = (); | ||
| 50 | |||
| 51 | foreach my $file ( @{ $result->content->{files} } ) { | ||
| 52 | push @committed_files, $file->{filename}; | ||
| 53 | } | ||
| 54 | |||
| 55 | return \@committed_files; | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; | ||
| 59 | |||
| 60 | =pod | ||
| 61 | |||
| 62 | =encoding UTF-8 | ||
| 63 | |||
| 64 | =head1 NAME | ||
| 65 | |||
| 66 | GitHub::EmptyRepository::Repository::Commit - Encapsulate select data about a GitHub commit | ||
| 67 | |||
| 68 | =head1 VERSION | ||
| 69 | |||
| 70 | version 0.00002 | ||
| 71 | |||
| 72 | =head1 AUTHORS | ||
| 73 | |||
| 74 | =over 4 | ||
| 75 | |||
| 76 | =item * | ||
| 77 | |||
| 78 | Thibault Duponchelle <thibault.duponchelle@gmail.com> | ||
| 79 | |||
| 80 | =item * | ||
| 81 | |||
| 82 | Olaf Alders <olaf@wundercounter.com> | ||
| 83 | |||
| 84 | =back | ||
| 85 | |||
| 86 | =head1 COPYRIGHT AND LICENSE | ||
| 87 | |||
| 88 | This software is copyright (c) 2022 by Thibault Duponchelle. | ||
| 89 | |||
| 90 | This is free software; you can redistribute it and/or modify it under | ||
| 91 | the same terms as the Perl 5 programming language system itself. | ||
| 92 | |||
| 93 | =cut | ||
| 94 | |||
| 95 | __END__ |