DEV Community

Play Button Pause Button
Brian Douglas for OpenSauced

Posted on

My FIRST open source contribution to the GitHub CLI

Open Sauced guides new contributors. Our approach towards onboarding offers a way to track contributions through the GraphQL powered dashboard.

How I thought of this contribution

My recent open source contribution happened while live streaming on twitch. Occasionally, at the end of a stream, I leverage the new GitHub CLI to list the project contributors and noticed the CLI does not filter out contributions from bots.

cli thank you credits

The top maintainers on my project are dependabot-preview[bot] and gh-action[bot], and as much as I appreciate their work, I would prefer the bots not listed in the "thank you credits."

With this problem, I had enough interest to make my first contribution.

Setting up my contribution

Before writing any code, I forked the repo to start researching a fix for this issue. I almost jumped right in with a fix after learning wherein the project to add this filter, but I opted to open an issue with my proposed solution as a way to wait for a response from the maintainers.

The CONTRIBUTING.md requests that contributors open issues before making any contributions.

My issue explanation included my desire to run the gh credits command with the option to filter for humans-only. You can read that issue below.

Ability to filter out bots in the credits #1597

Describe the feature or problem you’d like to solve

The top maintainers on my project are dependabot-preview[bot] and gh-action[bot]. I am opening this issue pre-emptively

I would like to run the gh credits command in contributor meetings, but with the option to filter for humans-only. TBH, I would like to make the human-only filter the default and make showing bots the option.

Proposed solution

How will it benefit CLI and its users?

I don't think having dependabot being the number 1 contributor in the list is useful to me or others and highlighting humans-only by default is preferred for now, or at least until the bots take over.

example of the option in use

gh credits open-sauced/open-sauced --bots
Enter fullscreen mode Exit fullscreen mode

running the credits without a flag should return only humans.

gh credits open-sauced/open-sauced
Enter fullscreen mode Exit fullscreen mode

I am new to cobra and a novice at Go, but this is the flag

    cmd.Flags().BoolVarP(&opts.Bots, "bots", "bts", false, "Include bots in the credits")
Enter fullscreen mode Exit fullscreen mode

Question

Is this needed?

I am aware I can get human-only names using grep, but unable to do that and get the cool animation

gh credits open-sauced/open-sauced | grep -v '\[bot\] $'
Enter fullscreen mode Exit fullscreen mode

Additional context

screenshots of what my output looks like today (includes bots).

Screen Shot 2020-08-28 at 8 29 14 AM

As an eager contributor, it is easy to miss this step announcing your interest in contributing. I have made what I thought were contributions to projects before, only to find out that the project was going a different direction and the code I committed was to a section marked for future deletion.

My contribution was accepted.

My wait lasted for a few hours for the first response and another few days for a :thumbs-up: to start working on my solution. The maintainers were friendly and offered suggestions and border solutions themselves. We concluded my answer was close but could be simplified, which was another reason why opening the issue first is the preferred first contribution.

You can view my merged solution below.

Filter gh credits for humans #1623

What is this?

The top maintainers on my project are dependabot-preview[bot] and gh-action[bot]. I am opening this PR in response to https://github.com/cli/cli/issues/1597.

Solution

I added another condition to leave out logins that are not humans (Users).

I ran the test in a Codespace and they passed, let me know if a new test is needed for this condition.

Screen Shot 2020-09-04 at 8 19 57 AM

Screenshot

no bots

Screen Shot 2020-09-04 at 9 10 07 AM

Join me in my open source journey

I dedicate my Friday Twitch streams to open source work and invite you to join that and our pre-stream-amas, where we chat through our ideas for open source contributions.

Watch me the full video on the Open Sauced YouTube channel.

Top comments (1)

Collapse
 
alexanderalemayhu profile image
Alexander Alemayhu

👏🏾👏🏾👏🏾