# GitHub project contribution badges

**URL:** <https://forum.confluent.io/t/github-project-contribution-badges/290>\
**Category:** Site Feedback\
**Created:** [1 December 2020 12:30 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290 "2020-12-01T12:30:22Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bruno/32/138_2.png) [@Bruno](https://forum.confluent.io/u/Bruno)\
**Post date:** [1 December 2020 12:30 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/1 "2020-12-01T12:30:23Z")

</div>

What is the difference between the GitHub project badges “Committer” and “Contributor”?

For Committer the description says “created a commit to [GitHub - apache/kafka: Mirror of Apache Kafka](https://github.com/apache/kafka)”

For Contributor the description says “contributed an accepted pull request to [GitHub - apache/kafka: Mirror of Apache Kafka](https://github.com/apache/kafka)”

Since I am not an Apache committer, I’ve never directly committed to Apache Kafka. All my contributions have been accepted pull requests. Nevertheless I have the Committer badge here. So I am wondering why and what the difference between “created a commit” and “contributed an accepted pull request” is. Similar applies to the other badges that contain the word “Committer” and “Contributor”.

Additionally, it seems that the definition of Committer and Contributor here and in Apache Kafka differ, which might be confusing.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [1 December 2020 15:23 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/2 "2020-12-01T15:23:26Z")

</div>

Yeah, I’m trying to figure this out @Bruno - I’d been discussing it with @mjsax too.

We’ve got the [GitHub - discourse/discourse-github](https://github.com/discourse/discourse-github) plugin setup, which pulls in contribution and commits from [GitHub - apache/kafka: Mirror of Apache Kafka](https://github.com/apache/kafka/).

Looking at [Contributors to apache/kafka · GitHub](https://github.com/apache/kafka/graphs/contributors) it shows you’ve got commits:

 ![2020-12-01_15-21-41](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/1bdef10bd425b90313f89eb1f7b59e9da76c3350.png)

Do you know what the terminology mismatch is here? We can retitle (or even disable) the badges as needed once we’ve figured it out.

---

<div class="post-metadata">

**Author:** ![Bruno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bruno/32/138_2.png) [@Bruno](https://forum.confluent.io/u/Bruno)\
**Post date:** [1 December 2020 15:55 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/3 "2020-12-01T15:55:30Z")

</div>

Thank you for looking into this @rmoff,

The commits that you see in the screenshot, all originate from accepted pull requests.

My question is what is the difference between  
“created a commit to [https://github.com/apache/kafka”](https://github.com/apache/kafka%E2%80%9D)  
and  
“contributed an accepted pull request to [https://github.com/apache/kafka”](https://github.com/apache/kafka%E2%80%9D)

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [1 December 2020 16:28 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/4 "2020-12-01T16:28:07Z")

</div>

I’m going to disable the `Committer` badges, because (a) it’s ambiguous in exactly the way you say, and (b) **Committer** is an overloaded term in the context of ASF, and if the plugin it using it in a different way then we’re going to confuse people

/cc @mjsax

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [1 December 2020 16:29 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/5 "2020-12-01T16:29:46Z")

</div>

So we now have these three github badges:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/e2b0bdaea12c5477d9611460282c42255e2f4b27.png)

I’ve just updated the thresholds, in theory we should see some users get Gold, I don’t know how often the refresh happens.

For ASF committers there is the `@committers` discourse group which is separate from the badges, and maintained manually.

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [1 December 2020 17:14 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/6 "2020-12-01T17:14:23Z")

</div>

Thanks Robin!

This makes sense to me. We should follow ASF terminology and use the  
term “committer” for well, committers only. And we have the  
corresponding group for those people.

Everybody else should be a “contributor” and the names of the three  
contributor badges make sense to me!

---

<div class="post-metadata">

**Author:** ![Bruno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bruno/32/138_2.png) [@Bruno](https://forum.confluent.io/u/Bruno)\
**Post date:** [1 December 2020 18:18 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/7 "2020-12-01T18:18:26Z")

</div>

Yes, removing “Committers” makes also sense to me.

Now, I am wondering why I am not an Amazing Contributor since I am amazing 😁 and I have more than 50 accepted pull requests.

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [1 December 2020 20:11 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/8 "2020-12-01T20:11:06Z")

</div>

I think the update is async – I also did not get the gold badge right away… Seems I am the only one who is amazing (for now) 😈

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [2 December 2020 10:01 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/9 "2020-12-02T10:01:31Z")

</div>

I found [this post](https://meta.discourse.org/t/github-badges-are-not-working-its-hard-to-see-if-i-do-something-wrong-or-if-the-plugin-is-not-working/148036/4?u=rmoff) which says that the refresh is every four hours.

I’ve logged a support ticket since this plugin seems kinda black-box (although the source code [is here](https://github.com/discourse/discourse-github) if anyone wants to take a look).

I’m wondering if the config that I set (`github gold badge min commits `) applies _only_ to **commits** and not **contributions** - this might make sense if the default threshold is 250 and @Bruno has 87 (\< 250) and @mjsax 385 (\>250)

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [2 December 2020 10:06 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/10 "2020-12-02T10:06:02Z")

</div>

The code’s here

> <https://github.com/discourse/discourse-github/blob/3ca98d36fb4756ad41848cd35c9d5703dc59a0d1/app/lib/github_badges.rb#L84-L112>

I’m not a ruby coder, but glancing at it it seems clear that there are some hardcoded thresholds being used as well as the configurable ones.

Let’s see what Discourse support come back with.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [3 December 2020 09:48 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/11 "2020-12-03T09:48:57Z")

</div>

Discourse support have come back with some info:

> Bruno has made 87 commits to the repo, but only 42 of those commits have been made with the ‘contributor’ role. His other commits were made with the ‘committer’ role

Looking at the Kafka repo for [@Bruno’s commits](https://github.com/apache/kafka/commits?author=cadonna) I think this is the difference that the badge plugin is making:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/925ffe62bbe4daa5a2dd5910b5883498f9326116.png)

So whilst Github counts all of this as commits:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/efa475383dc439df931101bdf930efec40785a81.png)

the plugin splits the difference between contributions (committed by someone else) and commits (committed directly).

What I’m not clear about is how someone who is not a Committer (in the ASF sense) on the Apache Kafka project can commit directly to the repo - @mjsax can you explain?

---

<div class="post-metadata">

**Author:** ![Bruno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bruno/32/138_2.png) [@Bruno](https://forum.confluent.io/u/Bruno)\
**Post date:** [3 December 2020 10:12 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/12 "2020-12-03T10:12:38Z")

</div>

I think the best would be to have a badge for the sum of contributions and commits because it would be the least confusing criteria to grant the badge. Don’t you think?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [3 December 2020 16:53 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/13 "2020-12-03T16:53:40Z")

</div>

I am not 100% sure, but only committers can merge PRs.

It seems that there is a cut-off point and older PR are labeled as “authored” while newer ones are labeled “committed”, thus, it might be a change how we merge PRs? But I am not sure what changed…

The only thing I could think of (but this changes happened earlier) is as follows: In early days, we could not merge directly on GitHub, because GitHub is not the primary repository but a mirror of a ASF hosted git; we still did PRs and reviews over GitHub, but merged those PRs into the primary ASF repos and the commit was mirrored into GitHub afterwards. – Later on, ASF allows us to merge directly on GitHub.

🤷‍♂️

I agree with Bruno though that it make not sense to no count all. It’s an artificial distinction.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [3 December 2020 17:55 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/14 "2020-12-03T17:55:16Z")

</div>

I’ve been poking around this some more.

The root issue seems to be that the plugin is picking up some _contributions_ (merged PRs) as _commits_. This means that the numbers are off, and users who do not have commit rights on the repo are incorrectly granted `committer` badges.

Here’re some examples, both PRs from @Bruno - who does not have commit rights on the repo :

- 20 Dec 2019 `1d21cf166a8ed7def514a1860318e74b64dd47da` [merged by `mjsax`](https://github.com/apache/kafka/pull/7841). Plugin categories this as a contribution (correctly).
- 29 Oct 2020 `a85b9440118ae5aa442d2e1e70b379841f941ddc` [merged by `ableegoldman`](https://github.com/apache/kafka/pull/9530). Plugin incorrectly categories this as a commit (incorrectly).

The `role` field is how it is viewing the commit vs contribution ([code](https://github.com/discourse/discourse-github/blob/3ca98d36fb4756ad41848cd35c9d5703dc59a0d1/app/lib/commits_populator.rb#L8-L11)):

```sql
SELECT * from github_commits
where sha IN ('a85b9440118ae5aa442d2e1e70b379841f941ddc','1d21cf166a8ed7def514a1860318e74b64dd47da')

```

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/50bc57aa48b04ab84d2a20a1ca05ae4daff8ab12.png)

This looks like the code that decides whether it’s a PR (contribution) or not:

> <https://github.com/discourse/discourse-github/blob/3ca98d36fb4756ad41848cd35c9d5703dc59a0d1/app/lib/commits_populator.rb#L74-L79>

Looking at the data the GitHub API returns we can see the values for the two commits above:

```nohighlight
$ curl --show-error --silent -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/apache/kafka/commits/1d21cf166a8ed7def514a1860318e74b64dd47da | jq '.commit.author,.commit.committer'
{
  "name": "Bruno Cadonna",
  "email": "bruno@confluent.io",
  "date": "2019-12-20T22:21:12Z"
}
{
  "name": "Matthias J. Sax",
  "email": "matthias@confluent.io",
  "date": "2019-12-20T22:21:12Z"
}

$ curl --show-error --silent -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/apache/kafka/commits/a85b9440118ae5aa442d2e1e70b379841f941ddc | jq '.commit.author,.commit.committer'
{
  "name": "Bruno Cadonna",
  "email": "bruno@confluent.io",
  "date": "2020-10-29T23:10:30Z"
}
{
  "name": "GitHub",
  "email": "noreply@github.com",
  "date": "2020-10-29T23:10:30Z"
}

```

So the second commit (`a85b9440118ae5aa442d2e1e70b379841f941ddc`) despite still being a PR that was merged, has fallen victim to the logic in the plugin code shown above, which says that if the committer name is `GitHub` then it _must_ be a direct commit by the author - and I don’t think that’s a valid assumption for it to make.

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [4 December 2020 09:33 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/15 "2020-12-04T09:33:35Z")

</div>

Do you think we could get the plugin changed? Or do we need to live with it as-is?

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [4 December 2020 09:56 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/16 "2020-12-04T09:56:03Z")

</div>

I’ve been emailing Discourse about this in parallel, and instead of duplicating comms have just invited @simon.cossar from Discourse to this thread 🙂

@simon.cossar it would be great to get feedback on :

1. Is the plugin faulty (as I believe it is, per the above) , since it is incorrectly counting _some_ contributions as commits?
2. Can we get the plugin fixed to act how we believe it should?
3. Failing that, can the plugin be enhanced, for example add a boolean config to `count commits under contributions` (which would fix our issue, I believe)

thanks, Robin.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [11 December 2020 07:11 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/18 "2020-12-11T07:11:40Z")

</div>

This has now been fixed, and deployed to our site 🎉

> <https://github.com/discourse/discourse-github/pull/24>
>
> This plugin ships with 2 types of badges: Contributor and Committer.
> Currently,… these badges are granted by replicating the git history of the
> configured repositories in the database using Github's REST API, and
> then looking up users by the emails on the commits and hand out badges.
> 
> A commit is considered a 'contribution' if it comes from a pull request
> that was not created and merged by the same user. The commits endpoint
> of Github's REST API doesn't include whether a commit comes from a PR or
> not. So, our only way to detect contributions is to compare the
> \`committer\` and \`author\` fields of the commit object that we get from
> the API. This method worked fairly well up until December 2019 when
> Github changed something that made the \`committer\` always be set to
> \`GitHub\` and not the user who merged the pull request.
> 
> So, this commit replaces the REST API with GraphQL which allows us to
> include pull request data (if any) with each commit object. This gives
> us a reliable way for detecting contributions.

@Bruno you now have all your well-deserved badges 🙂 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/db98bbdd435098dc81da33fd333bfc3fb4fd0abc.png)

---

<div class="post-metadata">

**Author:** ![Bruno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bruno/32/138_2.png) [@Bruno](https://forum.confluent.io/u/Bruno)\
**Post date:** [11 December 2020 09:26 UTC](https://forum.confluent.io/t/github-project-contribution-badges/290/19 "2020-12-11T09:26:01Z")

</div>

@rmoff Thanks a lot for following up on that!

@simon.cossar Thanks a lot for the support!

I think we have a badge now that is easily understandable by users of this forum.

@mjsax Finally, I am also amazing! 😁

Best,  
Bruno
