Lab 2 – My First PR

For this lab I was asked to add one of the optional features from Release 0.1 into a peers version of the URL tester.

After looking at a few repos I decided to add a feature to Mo’s url_tester. I chose this because I know how skilled Mo is at coding so I wanted to see how he tackled the issue since we both wrote it in Python.

The feature I added to Mo’s repo was an optional command line argument, –s, that will check to see if https can be used in place of http for the URL’s in a file.

At first glance it seemed like it was going to be an easy task but I did end up running into a few bugs. The first challenge was figuring out how to use the Click library that he used to process the command line args since I used argparse for that functionality. I first tried to add the optional argument on it’s own so that you could use the “–s” flag with any command.

That didn’t work though because of the way he had built his program so I ended up having to add it as an optional argument to the “file” command that he had set up.

After figuring out how to run that optional argument I then had to implement the logic to perform the task. This is the original:

I slightly modified his code by doing a conditional check to see if the “–s” flag is true or false. If true, then it will check to see if the URL is an http or https. If the former, then it uses a Regular Expression to replace the http with https and performs the Head request to see if it is still valid or not.

I then tested the code multiple times before committing and then finally making a Pull Request. I had made an issue made in Mo’s repository that I linked the PR to and after some time I had my first successful merge!

Design a site like this with WordPress.com
Get started