This week I have completed 1/4 pull request for Hactoberfest 2019

Image for post
Image for post
25% done (… I hope so)

Happy October!
This week I have completed my first pull request to a real project outside of our school, and at the same time, it was my first out of four pull requests participating in Hacktoberfest 2019!


I have contributed to the project, called Vmchecker — a virtual machine service that runs QEMU and Docker in a Nomad cluster. Being more specific, I have contributed to the UI interface repository of Vmck project — vmck/acs-interface.

What was the issue?

The issue number 22 stated that there are two equal pieces of code in two different parts of the project — and the proposal was to move it into a separate function to make the code more neat and clean.

So I left a comment, that I want to work on this issue and headed towards my first pull request!

Image for post
Image for post
First Comment

Work Process

I knew that I don’t have to change any functionality and my goal is to only move a few code pieces around. So I’ve started with forking this project in my GitHub repository and pulling it to my local machine. I created a branch issue-22 and started walking through the code.

I have never written or read code on Python. To understand, what is happening there, I started googling and bumped into w3schools website — notes on Python were very useful.

The files I’ve been looking at were models.py and utils.py. The piece of code to be managed was inside the vmck_config function of utils.py. The same block of code was called in the evaluate(self) function of models.py. The interesting fact was that this piece of code was called right before the call to the vmck_config function. Why do we need the same operations to be called twice? So I asked a question:

Image for post
Image for post
Do we?

After a little bit more code reading I’ve realized that we need the intermediate result of the operated piece of code later in the program, and this result can not be received any other way. I have realized that to save the functionality I have to create 3 new functions and spread the existing piece of code between them.

Image for post
Image for post
“The Great Discovery”

After that, I have successfully finished the get_url_base, get_config_data and get_config_url (the last one was renamed into get_script_url ) functions, committed the changes to my local repository, pushed it to the GitHub fork and filed my first Hacktober Pull Request!

Happy End?

Well, not yet. As you see from above, I have shown you only my comments on the issue — that is because I have not received any feedback till the next morning.

Image for post
Image for post
Well, could have been worse!

I have edited my code to follow the style guidelines and committed it once more to the same branch — and now I am waiting on my pull request to be merged.

Image for post
Image for post
Final Commit

So, What did I learn?

  1. def is a function declaration in Python;
  2. Put 2 newline characters before the new function declaration and 1 before the return statement;
  3. You don’t need to know the programming language to contribute to the project you like — a little bit of curiosity and stubbornness will get you to success;
  4. Don’t wait for anybody or anything — do what you can do;
  5. Open Source is Great.

My Functions:

def get_url_base(link):
m = re.match(r'https://github.com/(?P<org>[^/]+)/(?P<repo>[^/]+)/?$', link.assignment.repo_url)
url_base = ('https://raw.githubusercontent.com/''{0}/{1}/'.format(*list(m.groups())))
return url_basedef get_script_url(link):
url_base = get_url_base(link)
script_url = urljoin(url_base, f'{link.assignment.repo_branch}/checker.sh')
return script_urldef get_config_data(link):
url_base = get_url_base(link)
config_data = requests.get( urljoin( url_base, f'{link.assignment.repo_branch}/config.ini', ) )
return config_data

My GitHub repo:

Happy Coding and enjoy Hactoberfest 2019!

Image for post
Image for post

Written by

Student — Junior Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store