Review Existing Code

Setup

Project repository: py-demo-web-logs-continued

  • Fork the project repository to you your personal github account.

  • Clone your forked repository onto your personal machine.

Code Review

Note

In the example below we are cloning the github repo into the home/student/Desktop directory.

git-clone

Run the command git clone https://github.com/[your-github-username]/py-demo-web-logs-continued in your preferred directory.

View existing branches

This repository has three existing branches:

  • master
  • new-feature
  • new-function

git-branch-a

Run the command git-branch-a to view all existing local and remote branches.

Test Existing Code

The master branch main.py file currently prints information to STDOUT. You can check this behavior by running the main.py file within your directory.

python3-main-master

Run the command python3 main.py within your py-demo-logs-continued directory.

Branch: new-feature

Paul has come up with a solution to write the information inside of main.py to a file when run instead of only printing to STDOUT.

cat-main-new-feature

Checkout to the new-feature branch to test the behavior.

git-checkout-new-feature

  • run the command git checkout new-feature
  • run the command python3 main.py
  • run the ls command to check that a file was written to your directory
  • run the cat command to print the contents of web.log to Stdout
  • lastly, remove the file as we no longer need it

Branch new-function

John has also come up with a solution to write the information inside of main.py to a file but has created a function and called that function to handle the work. John also added in a newline character so that a newline is always triggered after the information has been displayed.

cat-main-new-function

Checkout to the new-function branch to test the behavior.

git-checkout-new-function

  • run the command git checkout new-function
  • run the command python3 main.py
  • run the ls command to check that a file was written to your directory
  • run the cat command to print the contents of web.log to Stdout
  • lastly, remove the file as we no longer need it

Recap

  • Reviewed existing code inside of master, new-feature, and new-function branches

Now that you are familiar with what code is inside of each branch you are going to need to merge all existing branches together.

Lets begin with the traditional git merge in the next walkthrough.