plu / Pithub

Perl Github v3 API

Home Page:http://metacpan.org/module/Pithub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

->commits

Tux opened this issue · comments

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.

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

  • Last commit (not last push date), preferable last commit per branch, but at the minimum the last commit date for the default branch
  • Number of open issues
  • Number of closed issues
  • Date of last action on most recent issue
  • Number of open Pull Requests
  • Number of closed Pull Requests
  • Date of most recent open PR
  • Date of most recent closed PR

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

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.

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

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