Forum

Gitlab: how to coun...
 
Notifications
Clear all

Gitlab: how to count all commits for branch

1 Posty
1 Users
0 Reactions
624 Widok
0
Topic starter

php curl example

1 Answer
0
Topic starter

We have to use workaround, iterating through contributors.

    function commitStatistics()
    {
        $ch = curl_init();
        $url = $this->projectUrl . '/api/v4/projects/24/repository/contributors';
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('PRIVATE-TOKEN:' . $this->secretToken));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);

        $total_counter = 0;
        foreach (json_decode($result) as $contributor) {
            $total_counter += $contributor->commits;
        }

        return $total_counter;
    }

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: