Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward integration results in strange language metrics #12

Open
alaendle opened this issue Mar 1, 2022 · 4 comments
Open

Forward integration results in strange language metrics #12

alaendle opened this issue Mar 1, 2022 · 4 comments

Comments

@alaendle
Copy link

alaendle commented Mar 1, 2022

If changes are merged (into a PR) they got attributed to the author (of the merge commit) - e.g. I suspect that Azure/iotedge#6114 brings me a lot of Rust-lines, however I have never touched a single line in a rust file.

I Know I kept very short; please let me know if this isn't self explaining or if I could contribute further information.

@inokawa
Copy link
Owner

inokawa commented Mar 1, 2022

Hi, @alaendle

The core of this gist is fetch user commits from GitHub API and counts them.
This gist has some filters to ignore not suitable commits but it may not be enough.

lang-box/src/index.js

Lines 56 to 57 in 33e344b

// Ignore duplicated commits
.filter((c) => c.distinct === true)

lang-box/src/index.js

Lines 79 to 80 in 33e344b

// Ignore merge commits
.filter((c) => c.parents.length <= 1)

If I could judge where the commits were came from, I may be able to fix it.
However some problems are probably impossible to fix because of the limitation of GitHub API.

@alaendle
Copy link
Author

alaendle commented Mar 1, 2022

@inokawa Many thanks for your reply. I now understand how deep the rabbit hole goes. The basic problem from my point of view is that YES technically I integrate/push all the commits from MAIN during a FI (the C's on MAIN) - however usually this is never my code and I don't like to count this code to my stats.


(cited from https://docs.microsoft.com/en-us/azure/devops/repos/tfvc/branching-strategies-with-tfvc?view=azure-devops)

However I have to admit that it isn't easy to distinguish the "right" commits from the "wrong" ones - simple there is no direct relationship between the GitHub user and the git user. So no solution would be perfect. The only thing that came to my mind is that some (maybe optional) filtering of the commits with regards to the git user name might solve these kind of misinterpretation.

@inokawa
Copy link
Owner

inokawa commented Mar 2, 2022

The only thing that came to my mind is that some (maybe optional) filtering of the commits with regards to the git user name might solve these kind of misinterpretation.

Looks nice.

It may be possible to put a filter like this

.filter((c) => c.author.name === 'foo')

.filter((c) => c.author.email === 'bar')

to

lang-box/src/index.js

Lines 56 to 57 in 33e344b

// Ignore duplicated commits
.filter((c) => c.distinct === true)

https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pushevent

Recently I don't have time to work on this, but it's ok to fix your own gist and PRs are also welcomed.

@alaendle
Copy link
Author

alaendle commented Mar 4, 2022

Hi @inokawa - many thanks for your kind support ❤️. I've just fixed my gist the way you suggested

alaendle/lang-box@c10b934#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556

My rare last name is finally paying off 😉

However I see no real generic solution - so I haven't created any PR for now.

btw, the famous https://github.com/bokub/github-stats-box suffers similar problems with regards to it's commit count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants