plu / Pithub

Perl Github v3 API
http://metacpan.org/module/Pithub
Other
68 stars 36 forks source link

->commits #195

Closed Tux closed 6 years ago

Tux commented 8 years ago

I'd like to see a method that returns me commits, like

my $repo = $ph->repos->get (user => "Tux", repo => "Text-CSV_XS");

my @commits = $repo->commits;
my @commits = $repo->commits ($repo->content->{default_branch}); # same
my @commits = $repo->commits (since => "20160101", branch => "testing");
my @commits = $repo->commits (limit => 15); # Only the 15 most recent commits

my $commit = $repo->commit ($sha);

Currently, ->content returns the most recent stamp for when the repo was pushed, but pashed_at does not tell me anything about the last commit for the default/stable branch, which - on a dashboard - imho is much more useful to show. If I read the docs correct, the commits can currently be fetched like

my @commits =
    sort { $b->{commit}{author}   {date} cmp $a->{commit}{author}   {date} ||
           $b->{commit}{committer}{date} cmp $a->{commit}{committer}{date} ||
           $b->{commit}           {date} cmp $a->{commit}           {date} }
    map  { @{ $_->content } }
    Pithub::Repos::Commits->new->list (user => "Tux", repo => "Text-CSV_XS");

Which seems to limit to the 100 most recent commits, and the list does not include branch information.

oalders commented 8 years ago

Have you looked at https://metacpan.org/pod/Pithub::Repos#commits ?

Tux commented 8 years ago

Yes, I did: see the last code snippet in above post. My ultimate goal is to get all the (recent) information about a repo into a single line of status/states, where I gather info from github, CPAN, and possible other sources like MetaCPAN and CPANTESTERS. Things I like te see on the dashboard are

All of those give me insight in how active the package is maintained

jjatria commented 6 years ago

Maybe things have changed a bit since 2016 (!), but I'm not sure if this issue is still in need of attention, since the desired behaviour is already provided with the existing API (even if in some cases it might be a bit verbose).

For example:

Last commit [...] per branch

my $result = $repo->branches;
while ( my $branch = $result->next ) {
    my $sha    = $branch->{commit}{sha};
    my $commit = $repo->commits->get( sha => $sha )->content;
    printf "%s (%.8s) %s\n", 
        $branch->{name}, $sha, $commit->{commit}{committer}{date};
}

If not, then maybe I'm just not understanding the issue, but I fail to see how a method like the one described could be implemented in a way that does not collide with the current API.

Tux commented 6 years ago

2016 indeed, and as nothing changed, I moved on to using other methods.

oalders commented 6 years ago

Looks like we can close this one. Feel free to reach out to me if I'm wrong.