# Method for Calculating Statistics of Developer Contribution to a Specified Branch.

7 messages from 2023-10-16 to 2023-10-31. Participants: Hongyi Zhao, brian m. carlson, Taylor Blau, Junio C Hamano.
Thread: https://gitlist.dev/t/60373

## Hongyi Zhao, 2023-10-16 14:10

Subject: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <CAGP6POKg4mSFv-Z+dD1aXDFDbxH9Xu1WCdCA5TGfCAM3NUUQLw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGP6POKg4mSFv-Z%2BdD1aXDFDbxH9Xu1WCdCA5TGfCAM3NUUQLw%40mail.gmail.com

```
Dear Git Mailing List,

I am a developer currently working on a project and I wanted to
establish statistics for each team member's contribution to a specific
branch.

Say, for a user "JianboLin", I am currently using the following method:

$ git clone https://github.com/OrderN/CONQUEST-release.git
$ cd CONQUEST-release
$ git log --author="JianboLin" --stat --summary origin/f-mlff | awk
'NF ==4 && $2 =="|" && $3 ~/[0-9]+/ && $4 ~/[+-]+|[+]+|[-]+/ {s+=$3}
END {print s}'

Using the above command, I am able to calculate the number of lines
contributed by a specific author on a specific branch, which allows me
to quantify the contribution to a branch by each team member.

However, I would like to know if a more efficient or accurate method
exists to carry out this task. Are there any other parameters,
commands, or aspects I need to consider to get a more comprehensive
measure of contribution?

I greatly appreciate your expertise and look forward to your valuable input.

Best Regards,

Zhao
-- 
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province

```

## brian m. carlson, 2023-10-16 21:25

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <ZS2qZtYDvItovjqg@tapette.crustytoothpaste.net>
URL: https://gitlist.dev/e/ZS2qZtYDvItovjqg%40tapette.crustytoothpaste.net
In-Reply-To: <CAGP6POKg4mSFv-Z+dD1aXDFDbxH9Xu1WCdCA5TGfCAM3NUUQLw@mail.gmail.com>

```
On 2023-10-16 at 14:10:01, Hongyi Zhao wrote:
> Dear Git Mailing List,
> 
> I am a developer currently working on a project and I wanted to
> establish statistics for each team member's contribution to a specific
> branch.
> 
> Say, for a user "JianboLin", I am currently using the following method:
> 
> $ git clone https://github.com/OrderN/CONQUEST-release.git
> $ cd CONQUEST-release
> $ git log --author="JianboLin" --stat --summary origin/f-mlff | awk
> 'NF ==4 && $2 =="|" && $3 ~/[0-9]+/ && $4 ~/[+-]+|[+]+|[-]+/ {s+=$3}
> END {print s}'
> 
> Using the above command, I am able to calculate the number of lines
> contributed by a specific author on a specific branch, which allows me
> to quantify the contribution to a branch by each team member.
> 
> However, I would like to know if a more efficient or accurate method
> exists to carry out this task. Are there any other parameters,
> commands, or aspects I need to consider to get a more comprehensive
> measure of contribution?

Can you maybe explain what you want to measure and what your goal is in
doing so?

The problem is that lines of code isn't really that useful as a measure
of contribution value or developer productivity, which are the reasons
people typically measure that metric.  For example, with three lines, a
colleague fixed a persistently difficult-to-reproduce problem which had
been affecting many of our largest customers.  That was a very valuable
contribution, but not very large.  I've made similar kinds of changes
myself, both at work and in open source projects.

Certainly you can compute the number of lines of code changed by a
developer, but that is not typically a very useful metric, since it
doesn't lead you to any interesting conclusions about the benefits or
value of the contributions or developer in question.  However, perhaps
you have a different goal in mind, and if you can explain what that is,
we may be able to help you find a better way of doing it.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

```

## Hongyi Zhao, 2023-10-17 11:37

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <CAGP6PO+SeZPzD21nErX=Vq=+d6oy-kg+diu=irot3enOhpQNMg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGP6PO%2BSeZPzD21nErX%3DVq%3D%2Bd6oy-kg%2Bdiu%3Dirot3enOhpQNMg%40mail.gmail.com
In-Reply-To: <ZS2qZtYDvItovjqg@tapette.crustytoothpaste.net>

```
On Tue, Oct 17, 2023 at 5:26 AM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2023-10-16 at 14:10:01, Hongyi Zhao wrote:
> > Dear Git Mailing List,
> >
> > I am a developer currently working on a project and I wanted to
> > establish statistics for each team member's contribution to a specific
> > branch.
> >
> > Say, for a user "JianboLin", I am currently using the following method:
> >
> > $ git clone https://github.com/OrderN/CONQUEST-release.git
> > $ cd CONQUEST-release
> > $ git log --author="JianboLin" --stat --summary origin/f-mlff | awk
> > 'NF ==4 && $2 =="|" && $3 ~/[0-9]+/ && $4 ~/[+-]+|[+]+|[-]+/ {s+=$3}
> > END {print s}'
> >
> > Using the above command, I am able to calculate the number of lines
> > contributed by a specific author on a specific branch, which allows me
> > to quantify the contribution to a branch by each team member.
> >
> > However, I would like to know if a more efficient or accurate method
> > exists to carry out this task. Are there any other parameters,
> > commands, or aspects I need to consider to get a more comprehensive
> > measure of contribution?
>
> Can you maybe explain what you want to measure and what your goal is in
> doing so?
>
> The problem is that lines of code isn't really that useful as a measure
> of contribution value or developer productivity, which are the reasons
> people typically measure that metric.  For example, with three lines, a
> colleague fixed a persistently difficult-to-reproduce problem which had
> been affecting many of our largest customers.  That was a very valuable
> contribution, but not very large.  I've made similar kinds of changes
> myself, both at work and in open source projects.
>
> Certainly you can compute the number of lines of code changed by a
> developer, but that is not typically a very useful metric, since it
> doesn't lead you to any interesting conclusions about the benefits or
> value of the contributions or developer in question.  However, perhaps
> you have a different goal in mind, and if you can explain what that is,
> we may be able to help you find a better way of doing it.

I want to calculate a certain developer's contribution based on
different standards of code line count and the importance of the code.

> --
> brian m. carlson (he/him or they/them)
> Toronto, Ontario, CA

Regards,
Zhao

```

## Taylor Blau, 2023-10-30 21:49

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <ZUAk6dPJyhfb7UBM@nand.local>
URL: https://gitlist.dev/e/ZUAk6dPJyhfb7UBM%40nand.local
In-Reply-To: <CAGP6PO+SeZPzD21nErX=Vq=+d6oy-kg+diu=irot3enOhpQNMg@mail.gmail.com>

```
On Tue, Oct 17, 2023 at 07:37:46PM +0800, Hongyi Zhao wrote:
> I want to calculate a certain developer's contribution based on
> different standards of code line count and the importance of the code.

I agree with brian that "number of lines added/removed" is not a perfect
measure of productivity ;-).

But I think that there is a slightly cleaner way to compute the result
you're after, like so:

    git rev-list --author="$who" origin/main |
    git diff-tree --stdin -r --numstat --no-commit-id |
    awk '{ s += $1 + $2 } END { print s }'

Thanks,
Taylor

```

## Hongyi Zhao, 2023-10-31 05:09

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <CAGP6POK2yABRhJHQYfOFZ2h6BSy9XU6aZbnBaA11TJiEnBAa6g@mail.gmail.com>
URL: https://gitlist.dev/e/CAGP6POK2yABRhJHQYfOFZ2h6BSy9XU6aZbnBaA11TJiEnBAa6g%40mail.gmail.com
In-Reply-To: <ZUAk6dPJyhfb7UBM@nand.local>

```
On Tue, Oct 31, 2023 at 5:49 AM Taylor Blau <me@ttaylorr.com> wrote:
>
> On Tue, Oct 17, 2023 at 07:37:46PM +0800, Hongyi Zhao wrote:
> > I want to calculate a certain developer's contribution based on
> > different standards of code line count and the importance of the code.
>
> I agree with brian that "number of lines added/removed" is not a perfect
> measure of productivity ;-).
>
> But I think that there is a slightly cleaner way to compute the result
> you're after, like so:
>
>     git rev-list --author="$who" origin/main |
>     git diff-tree --stdin -r --numstat --no-commit-id |
>     awk '{ s += $1 + $2 } END { print s }'

See below:

werner@X10DAi:~/Public/repo/github.com/OrderN/CONQUEST-release.git$
git log --author="JianboLin" --stat --summary origin/f-mlff | awk 'NF
==4 && $2 =="|" && $3 ~/[0-9]+/ && $4 ~/[+-]+|[+]+|[-]+/ {s+=$3} END
{print s}'
8519
werner@X10DAi:~/Public/repo/github.com/OrderN/CONQUEST-release.git$
git rev-list --author="JianboLin" origin/f-mlff |     git diff-tree
--stdin -r --numstat --no-commit-id |     awk '{ s += $1 + $2 } END {
print s }'
8519

So, your method and my original one give exactly the same result.
Therefore, I can't see what their fundamental difference is.

> Thanks,
> Taylor

Regards,
Zhao

```

## Junio C Hamano, 2023-10-31 06:25

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <xmqqsf5r2tr3.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqsf5r2tr3.fsf%40gitster.g
In-Reply-To: <CAGP6POK2yABRhJHQYfOFZ2h6BSy9XU6aZbnBaA11TJiEnBAa6g@mail.gmail.com>

```
Hongyi Zhao <hongyi.zhao@gmail.com> writes:

>> But I think that there is a slightly cleaner way to compute the result
>> you're after, like so:
>> ...
> So, your method and my original one give exactly the same result.
> Therefore, I can't see what their fundamental difference is.

I think Taylor offered a "slightly cleaner way", and not a
"different way that computes better result".  So it is not
surprising, at least to me who is watching from the sideline, that
you cannot see any fundamental difference.

```

## Taylor Blau, 2023-10-31 19:05

Subject: Re: Method for Calculating Statistics of Developer Contribution to a Specified Branch.
Message-ID: <ZUFP9bQe5FL8QYDn@nand.local>
URL: https://gitlist.dev/e/ZUFP9bQe5FL8QYDn%40nand.local
In-Reply-To: <xmqqsf5r2tr3.fsf@gitster.g>

```
On Tue, Oct 31, 2023 at 03:25:36PM +0900, Junio C Hamano wrote:
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> >> But I think that there is a slightly cleaner way to compute the result
> >> you're after, like so:
> >> ...
> > So, your method and my original one give exactly the same result.
> > Therefore, I can't see what their fundamental difference is.
>
> I think Taylor offered a "slightly cleaner way", and not a
> "different way that computes better result".  So it is not
> surprising, at least to me who is watching from the sideline, that
> you cannot see any fundamental difference.

Indeed.

Thanks,
Taylor

```
