Yet another way Git make the review process better

As you may know from some of my posts, I am a frequent user of GitHub.  When I started using it I didn’t realize how powerful it was. However, as time goes on, Git is looking to be more and more of a manager’s tool. When I first volunteered to help manage the processing-js project I wrote a set of guidelines that incorporated the use of Lighthouse and GitHub. The basic principle was “tell people what you are working on and the status” on Lighthouse, “do your work and let others look at it” on GitHub and finally “ask people to review” on Lighthouse.  It now seems that GitHub has the ability to do all of the aforementioned items.

Pull Requests

Once you have finished a patch you can request that the owner of the repository who’s code you have forked reviews it. This is done by selecting the pull request button which opens up a discussion between you and the person who owns the repository you have a fix for. Like I mentioned this is a discussion, you and the other person can go back and forth several times before he/she is ready to pull (accept and add to their repo) your code. Git will tell you when a new note was added to the discussion or when any other actions were taken. A pull request is a fast and easy way to see all of the commits associated with the pull request without having to leave the page.

Commit Notes

Once you have committed anything to git you will get a commit url (example). This is a summary of all of the files that were changed including their specific line numbers as well as the before and after identified with a (-) and a (+) sign. This lets the person looking at your patch know exactly what you added/replaced/deleted. When a person looks at the commit with the intention of reviewing it, he/she can add comments to any line that you have edited. This is done by clicking on the line number of the file you would like to add your note to. Here is a sample commit with notes.

I think you probably know where i am going with this. If a person has a patch there is no need for them to go on lighthouse and comment on a ticket. Further, there is no need for the reviewer to comment on their patch on lighthouse. All that is needed here is Git. Git gives you the ability to ask for review, get comments on a review, fix any issues, request another review, and have your code accepted all under one discussion. I know what you are thinking, how does one replace the bug tracker in order to ensure no two people are fixing the same bug. Which brings me to another one of GitHub features, git pages.

GitHub Pages

GitHub allows you to add a custom page to your repository. This page can be whatever you want it to be. You can use it to list the functionality you have yet to implement or you can simply point it to a wiki where that list can be found. Here is a short guide on github pages.

View all of my blogs on GitHub
View all of my blogs

Advertisements

Installing Git on Max OS

If you have been following my blog you would know that I have been working with Git for a while but on my Vista machine. Getting started with Git can be challenging so in order to be able to easily reproduce my steps I have created 2 separate blogs about it. #1 Setting Up GitHub on Windows #2. Adding Code To GitHub Now that I will be working on an iMax i have decided to do the same. The challenge here is to learn how to install things on the Mac (this is my first week using the not configured Mac OS) and also to figure out how to link Git to my existing repo without braking my Windows configuration.

After some googling i found a helpful site courtesy  of  git: check it out here

Installing xCode

In order to run the make command you need to install xCode . xCode is a developer tool that will enable you to make iPhone and Mac OS applications. In order to download xCode you have to make an Apple Developer Account on their site. Once you are logged in go to the Downloads section and under Snow Leopard Downloads click on the xCode 3.2.2 and iPhone SDK link (note that by the time you do this the version may have changed).

Once the file is downloaded open the containing folder and double click on the .dmg file (i think the icon for all of these file types is a 3D box) Once you have double clicked on it you will get a pop-up window guiding you through the installation. Don’t fly through the process because one of the windows will ask you which features you want to install and not all of them are check-marked by default (i ensured all of them are). Here is a snap shot of the installation video:

When the installation finished you should see a big green check mark (the first time i run the installer it failed and i didn’t even notice). Also, if you click on the magnifying glass located in the top right corner of the desktop and type in xcode you should see it listed as an application.

Download and Install Git

In order to install Git download git-1.7.1.tar.bz2 (version might be different) from Git.

  • Open the terminal application and change to the Downloads directory (assuming that where git downloaded): cd ~/Downloads
  • Unzip the file: tar -xjf git-1.7.1.tar.bz2
  • Switch to the Git directory: cd git-1.7.1
  • Make git and put it in the /opt/git folder for easy removal: make prefix=/opt/git
  • Install the compiled binaries: sudo make install prefix=/opt/git

The next step is installing man pages but since i dont have MacPorts ill go over that first

Installing MacPorts

To install MacPorts visit their download site and under the Mac OS X Package (.pkg) Installer section download the.dmg for your OS (I chose the SnowLeopard one). Once the file downloaded double click on it and an installation window will open similar to the xCode one i described above.

Setting up Man Pages

Git man pages are not yet installed so you should install them because they are very helpful

  • Get them (this takes a while, use -d after port if u get stuck): sudo port install asciidoc xmlto
  • make man prefix=/opt/git
  • sudo make install-man prefix=/opt/git

Public keys

Check out this tutorial on setting up public keys. Now if you already have Git set up on another machine use the tutorial to generate the keys/files and then edit the files manually.

Complete

You are now ready to run git commands. Use clone to get a local copy of your repository.

  • git clone git://github.com/restofURL dirName

View all of my blogs on GitHub
View all of my blogs

Lighthouse + GitHub

A couple of releases ago the processing.js project team decided that a bug tracker is needed to keep track of needed fixes and missing-features. We decided Lighthouse was a good and free application.  Here is the link to the processing.js lighthouse project.  Lighthouse has been working great but sometimes developers (including me) think it is too much work. Due to this, most of our tickets go from I started working on this….. to I am done here it is. This is fine but often the ticket is in the “I started working on this” stage for 2+ weeks. This makes it hard to distinguish between tickets that are just started or actually in the process of getting solved.

A couple of days ago, while doing a ‘bulk edit’ on some tickets, I realized that you can join Lighthouse and GitHub. This is great because anytime you commit to GitHub  using the command git commit -m” ” you can actually put in keywords that will be recognized by Lighthouse. So once you push your changes to GitHub, Lighthouse goes over the keywords and updated the ticket. The only downfall with this is that you cannot add a message to the ticket, instead Lighthouse adds your commit message. So you have to make sure the commit message is clear and contains enough information.

Steps for linking Lighthouse and GitHub

  1. Create an API token in Lighthouse
  2. Add the API token to GitHub
  3. Learn the commit message keywords
#1 Create an API token in Lighthouse

In order to create an API token in Lighthouse you have to go to the ‘My Profile’ section. The easiest way to do this is to click on you username in  the top right hand corner:

This will bring you to your profile. Now on the right hand side you will see a ‘Create an API token’ section with a drop-down list of all the projects that you are a member of:

Simply select ‘processing-js’ from the drop-down menu. Lighthouse will then provide more options: label, access, and project. Fill in anything you want for the label. The access must be full access. Finally select the project and press create.

Lighthouse will generate a Token and display it on the screen. In a newly created ‘Your API Tokens’ section. Copy the token, you will need to put it into GitHub.

#2 Add the API token to GitHub

Log into your GitHub account select your project repository and go into the admin section by pressing the ‘Admin’ button. In the admin section you will find a ‘Service Hooks’ button. Select it:

This will display all of the services that GitHub provides. Select Lighthouse from the list of Hooks, and fill out the form that appears on the right. Notice, GitHub provides instructions on how to do this below the form. However, for our processing project the subdomain is processing-js, the project id is 41284, the token is the token you copied from LightHouse. Ensure you set the ‘Active’ checkmark, and press Update Settings.

#3 Learn the commit message keywords

Lighthouse has many keywords that enable you to change who’s responsible, the milestone and the state of the ticket. Here is a list of keywords. Here is a screenshot of a ticket that has been automatically updated by LightHouse:

If you are having trouble understanding my post please read: Setting Up Communication between GitHub Repositories and Lighthouse Projects via a Secure Token

View all of my blogs on Processing.js
View all of my blogs

Adding new Code to your GitHub Repository

Previously, I posted a tutorial on setting up GitHub and Git Bash. Now I would like to show you how to get new code into ur repository.

Steps:

  1. Create a local Branch
  2. Create a remote Branch
  3. Add files to your local Branch
  4. Commit changes to your local Branch
  5. Push the new branch to GitHub

Those are the steps, now before we get started bookmark this Git cheat sheet its a good reference.

Note: all commands are entered in Git Bash command prompt. How do u open it? On Vista, Start -> Search for Quick->Right click ‘Quick Launch’ result->Select ‘Git Bash Here’

Create a Local Branch

A local branch is a version of your code package saved on your home machine. I believe you can have as many branches as you want.

  1. git branch <branch name>

Create a Remote Branch

A remote branch is one that sits on the GitHub social coding site, users can select this branch and download code that belongs to this branch alone.

  1. git push origin origin:refs/heads/branch name>

The command window will give you a confirmation:

Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:annasob/processing-js.git
* [new branch]      origin/HEAD -> withCursor2-

——————————————————————

Total 0 (delta 0), reused 0 (delta 0)

To git@github.com:annasob/processing-js.git

* [new branch]      origin/HEAD -> withCursor2

——————————————————————

If you get an error saying repository not found make sure your config file is correct. Here is a snippet:

——————————————————————-

[remote “origin”]

fetch = +refs/heads/*:refs/remotes/origin/*

url = git@github.com:annasob/processing-js.git

[branch “master”]

remote = origin

merge = refs/heads/master
——————————————————————

Add files to your local branch

I am not sure if this makes a difference, but i just opened the processing-js directory I was working in and dragged any new files/folders I needed to have.  Alternatively, you can use these commands, well first you have to tell Git which branch you are going to be working with:

  1. git checkout <local branch name>
  2. git add <filename or directory>

Commit changes to your local Branch

Before you can submit the changes to GitHub, you have to commit them on your local machine.

  1. git commit -a

This command will commit all of your changes and allow you to write a message in vim. Vim guide.

The message should be significant, as everyone will read it to see whats new from the previous versions.

Push the new branch to GitHub

Now you are ready to update the remote branch.

  1. git push git@github.com:annasob/processing-js.git <remote branch name>

Note: you will need to put your own repository path in. Here is the message you will see:

——————————————————————–

Counting objects: 7, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (3/3), done.

Writing objects: 100% (5/5), 617 bytes, done.

Total 5 (delta 1), reused 0 (delta 0)

To git@github.com:annasob/processing-js.git

8e069aa..dd33dfd  withCursor -> withCursor

———————————————————————-

After you do all of this, log in to ur GitHub account and go to your repository. If you roll over ‘all branches’ you will see your new branch. Select it and try downloading the contents to ensure that nothing is missing.

Note, I have reported a bug, somehow the download functionality in GitHub doesn’t always work.

Hope this tutorial helps 🙂 Feel free to post comments.

View all of my blogs on GitHub
View all of my blogs

GitHub Bug

I spent the last week working on uploading a new branch to GitHub using Git Bash (tutorial coming soon). If you are still trying to set up GitHub and Git Bash check out my tutorial HERE.

All this for a simple upload? The basic steps are: create a branch both remote & local, put your new files/folders into the repository directory on ur local machine, make sure Git Bash prompt is working with this branch, commit ur work including a message, push the repository back to GitHub.

It seems like a simple process, and it might still prove to be.

I must have done the steps a million times, but every time I logged on to my account on GitHub, pointed the browser to the correct branch, and downloaded the ZIP file I found none of my changes. I couldn’t figure out what was going on.

Finally, I spoke to Alistair MacDonald (F1LT3R) on IRC (Mibbit ), and he helped me thorough the steps of making a branch and uploading it. Still, the download didn’t contain any of my updates.

GitHub Download Menu

GitHub Download Menu

I noticed that on the download menu (pic above) the captions said at main (right now 51d280c). I found a BUG?? So even though I selected the new branch, GitHub was still pulling information from my main branch. Anyhow, I documented the Bug by adding a discussion topic. Check it out! Apparently the bug has been resolved “The page was cached with a bad link, it should download the correct branch now.” But I just downloaded, and I am now missing files that were previously there on top of missing the updates. Stay tunned…

View all of my blogs on GitHub
View all of my blogs

Setting up Git/GitHub on Windows

I have a Vista machine and i needed to set up Git and GitHub in order to finish my processing.js project.

What is Git and GitHub? Basically it is an online code sharing community that uses repositories to maintain code versions.

What will u need to do?

  1. Set up a free account on the GitHub social network and a repository
  2. Download and install Source Code Management tool
  3. Link the two together

Set up a free account

Sign UP

Sign UP

 

  • Click “Sign Up” in the Open Source table
Free Option

Free Option

  • Fill in the registration form (leave SSH Public Key blank)

Setting up a repository

So there should only be one code repository per project. If a repository DOESN’T exist u can create one. However, if it DOES exist then you have to fork it.

FORK: By forking a project instead of cloning, creating a new GitHub repo, and pushing to it, you allow us to create a link between your fork and the original. This link helps us keep you informed of changes to the original codebase and make it trivial for you to notify the originator of changes that you have made and would like have reviewed.

For the purpose of my setup, I will be forking an existing processing.js repository

  • If u are not logged in (to GitHub), log in. This will bring u to the home page, if not click on the GitHub Social Coding logo on the upper left corner of the page.
GitHub Home

GitHub Home

  • Click on “Find a Repository”
  • Type “processing.js” in the search textbox (don’t change any defaults) and press enter
Search For Repository

Search For Repository

  • Select the “jeresig/processing-js”  Repository
  • Select the “fork” button (found beside the repository name)
Fork

Fork

Download and install Source Code Management tool

For windows, you can use cygwin or msysgit. I am using msysgit.

  • Download the latest version from Google Code. Run the executable
  • Press “Next” for most of the configuration except for the following screens:
Git Configuration

Git Configuration

Git Configuration

Git Configuration

Git Configuration

Git Configuration

  • Once Setup is complete, you can generate your SSH key. Open up the msysgit cmd: Start=> Search for “Quick Launch” folder => right click => Select “Git Bash Here”
Quick Launch

Quick Launch

  • The command window should open up. Type ssh-keygen -C “youremailinquotes@com” -t rsa to create a key. Here is another tutorial on SSH Keygen.

SSH Key

SSH Key Gen

Note: You do not need to put in any input after the ssh-keygen command, just press enter after every prompt.

  • Identify yourself on Git using these two commands:

  1. git config –global user.name “yournameinquotes”
  2. git config –global user.email youremail@com
  • Tell GitHub apps about u. Log into GitHub, select “Account” (top right corner), select “Global Git Config”. Copy and paste the commands in the pop-up into the Git Bash command prompt.
Git Blobal Configuration

Git Blobal Configuration

Link the two together

  • Add SSH key you just created into GitHub. Open SSH key in a text editor.  Looking back at the ssh-keygen command, you identified “C:\Users\YourNameHere\.ssh\” as the path. Open this folder (it might be hidden). Open id_rsa.pub in a text editor and copy its entire contents.
  • Go back to your GitHub Account and just under the “Global Git Config” we used 2 steps above u will find the “SSH Public Key” Section. Click “Add a Key” and paste the SSH key into the “Key” textarea. DO NOT include any extra spaces. You can leave the “Title” blank if u wish. Don’t forget to press “Add Key”
Add the SSH Key

Add the SSH Key

  • Test to make sure that everything works. On the Git Bash command prompt type the following command: ssh git@github.com I got a connection confirmation prompt and I had to type yes.

Verification

Verification

  • Get the actual code in the Repository using this Git Command: git clone git://github.com/annasob/processing-js.git processing
  • To get the path of ur repository: Log into GitHub. On the homepage click on the Repository you want to clone. Once the repository information comes up look for “Public Clone URL” or “Your Clone Url”

 

View all of my blogs on GitHub
View all of my blogs