Count lines added by a developer

Hi guys,

I would like to write some webhooks to gather data about our users’ actions and right now I am interested in counting the number of lines added and deleted by each developer.

In each push event the webhook receives the commits pushed by the developer.

Is there a way to count the number of lines added or deleted by each commit?

Thanks a lot.

This sounds cool! Do you mind sharing some more details of the webhook? I did a little bit of looking around and I believe this could be accomplished with a variation of git diff while using the –stat flag.

There is a pretty good post on SO that had similar parameters to what you’re trying to do: https://stackoverflow.com/questions/2528111/how-can-i-calculate-the-number-of-lines-changed-between-two-commits-in-git

Looks like you’ll be able to get a good amount of information depending on the options you use with either git diff or git log.

Sounds like a cool webhook - would love to hear more!

J

@jamesmundia

Thanks for your reply, I can use this api endpoint GET /projects/:id/repository/commits/:sha found here to get the information I want.

I am still planning my project, I will share info with you once I have a good version to start with.

I would like to enable the users of Gitlab CE to get information about the activities of their users with help from webhooks.

Thanks again.

Thank you for the API link! Are the stats contained in the example responses for a single commit (https://gitlab.com/help/api/commits.md#get-a-single-commit) and cherry picked commit (https://gitlab.com/help/api/commits.md#cherry-pick-a-commit) suitable for you?

Did you ever get this working?