tan-tan-kanarek / github-php-client

MIT License
184 stars 120 forks source link

Showing Files commited #45

Closed adahox closed 9 years ago

adahox commented 9 years ago

hey, i'm want show the files included on commit. but i dont find the function to do it.

tan-tan-kanarek commented 9 years ago

Use this example:

        require_once(__DIR__ . '/client/GitHubClient.php');

        $owner = 'tan-tan-kanarek';

        $repos = array(
            'github-php-client',
        );

        $client = new GitHubClient();

        foreach($repos as $repo)
        {
            $client->setPage();
            $client->setPageSize(4);

            $commits = $client->repos->commits->listCommitsOnRepository($owner, $repo);

            foreach($commits as $commit)
            {
                /* @var $commit GitHubCommit */
                $sha = $commit->getSha();
                $url = $commit->getUrl();
                $message = $commit->getCommit()->getMessage();
                $committerLoginName = $commit->getCommitter()->getLogin();
                $authorLoginName = $commit->getAuthor()->getLogin();

                echo "$sha - [$committerLoginName/$authorLoginName] $message\n";

                $fullCommit = $client->repos->commits->getSingleCommit($owner, $repo, $sha);
                foreach($fullCommit->getFiles() as $file)
                {
                    /* @var $file GitHubFullCommitFiles */

                    echo "\t- " . $file->getFilename() . "\n";
                }
            }
        }