Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tracking OpenStack contributions in GitHub

DZone's Guide to

Tracking OpenStack contributions in GitHub

· Cloud Zone ·
Free Resource

Insight into the right steps to take for migrating workloads to public cloud and successfully reducing cost as a result. Read the Guide.

I've switched my Git repositories to GitHub recently, and started to watch my contributions statistics, which were very low considering I spend my days hacking on open source software, especially OpenStack.

OpenStack hosts its Git repositories on its own infrastructure at git.openstack.org, but also mirrors them on GitHub. Logically, I was expecting GitHub to track my commits there too, as I'm using the same email address everywhere.

It turns out that it was not the case, and the help page about that on GitHub describes the rule in place to compute statistics. Indeed, according to GitHub, I had no relations to the OpenStack repositories, as I never forked them nor opened a pull request on them (OpenStack uses Gerrit).

Starring a repository is enough to build a relationship between a user and a repository, so this is was the only thing needed to inform GitHub that I have contributed to those repositories. Considering OpenStack has hundreds of repositories, I decided to star them all by using a small Python script.

!/usr/bin/env python
from github import Github

USERNAME = "myusername"
PASSWORD = "mypassword"
USERS = ("openstack", "stackforge", "openstack-dev", "openstack-infra")

g = Github(USERNAME, PASSWORD)
me = g.get_user()

for username in USERS:
    user = g.get_user(username)
    for repo in user.get_repos():
        me.add_to_starred(repo)
        print("Starred %s" % repo.full_name)

And voilà, my statistics are now including all my contributions to OpenStack!

TrueSight Cloud Cost Control provides visibility and control over multi-cloud costs including AWS, Azure, Google Cloud, and others.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}