In this lab I was asked to implement two additional features into my checkThatLink application. Specifically, I was asked to do the work for each feature in independent branches in order to simulate two different people adding features to the same master branch. This will help familiarize me with the merging process.
The first issue I choose to implement was to add an optional flag to signal that the display should be in JSON format. The second issue was an optional few optional flags to signal if all, good, or bad links should be displayed.
To start off I made two separate branches, one for each issue. I then decided to implement one issue after another, starting with the JSON issue. All I had to do for this was add in the argument and then added functions that where almost identical to the custom print functions I had. The only difference being that the status and URL got appended to a list instead of printing it immediately to stdout. I could then use the regular print or the JSON print depending on the condition of the flag.
if(not self.jsonOut):
self.printStatusCode(line)
if(self.secureCheck):
self.secureHttpChecker(line)
else:
self.printStatusAsJSON(line)
if(self.secureCheck):
self.secureHttpCheckerJSON(line)
if(self.jsonOut):
print(self.json)
All these changes can be found here in the commit log.
Ok, first issue complete. After switching back to my master branch I made a merge request for the completed feature branch. Since there are no conflicts it performed a fast forward merge. Success, now to implement the other feature.
After checking out to the other working branch I started to implement the options. There was a couple of ways I thought about doing it but I finally decided just to load all the results into a single array. I then made three different print functions that would get called with a corresponding flag.
if(self.good):
self.printGoodResults()
elif(self.bad):
self.printBadResults()
else:
self.printAll()
If you want to see more details you can check out the full commit file for this issue.
Ok, now it’s time to merge again. Last time was easy, should be the same again this time right…
This merge was much more involved then the first one since the master branch had been updated before committing the second feature. After some time looking at the differences I thought it would be best if I merged my ideas manually. I did this by taking the idea of making three separate print functions from the second issue and applying that with my strategy for displaying the output as JSON. The end result looked like this.
if(self.good):
if(self.jsonOut):
self.printGoodResultsJSON()
else:
self.printGoodResults()
elif(self.bad):
if(self.jsonOut):
self.printBadResultsJSON()
else:
self.printBadResults()
else:
if(self.jsonOut):
self.printAllJSON()
else:
self.printAll()
After finally making all the needed adjustments and doing a ton of testing I made my final commit and pushed my master branch into origin. You can just call me Mix-Master-Merge.