Sunday, 17 February 2013

CIMI client

As I have mentioned in previous posts, I have been working with Deltacloud project. This post is about the code I have been working on. As the title tells, I have been working on CIMI client - getting it working. It's a Sinatra app. There were a few bugs here and there that I have been fixing and adding new stuff.

I started by going though the entire app and noting the issues that I came across, eg broken links and the like. From my notes of issues, I wrote some JIRA tickets which I started working on. The first issue that I dealt with if fixing all broken links. This basically meant creating all the missing pages. This was a great task to start with, as I got me even more familiar with the code. After sending out a few of these patches to the dev mailing list, my code was pushed to master -> Woohoo! :)

The pages that I created were index and show pages for CIMI resources. This was not all that tricky as there were some great helpers already written for the front-end.  My next task was writing code for creating new entities. This was a little challenging, because I came across enough bugs/issues while writing this code. From Ruby bugs to bugs in the methods I was using. As I much as it was great that I found the issues and filed JIRA tickets for them, I felt 'slowed-down' enough. It's easy to feel unproductive after a whole day of chasing after a bug.

With most of the bugs fixed, I sent out the patches for creating some entities, which is great! I am looking into writing sending out the rest of the patches on creating entities, and move to my next task => Change the code so that CIMI client does not explicitly construct URL's but rather  uses the URL's the server sent it. That should be fun! :)

Tuesday, 5 February 2013

Git, a FOSS programmer's best friend

Since I started working on the Deltacloud project, Git has become my best friend friend. I was using git before on my own work, but I have coming to believe one can only enjoy the full power of Git when working on an open source project.

I had to learn a number of new git commands to work effectively and thought it'll be a great idea to share. The commands I will mention include cloning a repo, getting the latest changes, creating a branch, commiting your changes, creating a patch, sending a patch and applying the patches of other developers. I will share this by going through the process I use. 

$ git clone git://

This is the first step one usually takes, I ran this last while working on my small contribution for applying for the internship. I'm pretty sure most people have used this before. Know an open source project you like, then you need to run this command and happy coding!

$ git pull

I run this code to get the latest changes on master before making any changes of my own. I do this often to keep my code up-to-date.

$ git checkout -b working_branch

This command basically create a new branch from master. This is where I will work on the code from. After writing code to a certain point, e.g, fixed a bug, you can commit your changes with the following commands. Please note that code relating to a certain issue should be commited as one commit. This is because they the different commits will create the different patches, and you definitely want relating code in one patch.

$ git add .

This will stage your changes for commit.

$ git commit -m "a commit message that makes sense"

This command, as you might have guessed, commits your changes. Most important thing here is the git message. It should summarize the your changes in a few words, and be very clear. It's important for these reasons: The message will be used as the subject of the patch (If you do not change this) and the other developers need to know that what your commit is all about. As I have come to learn, communication is key in open source projects.

$ git rebase master

Running this command is very critical - I am talking out of experience! This is apply your commits against master ensure ensure there are no conflicts. Next, you create your patches.

$ git format-patch master

This checks your commits against master and creates a patch for each commit. This will create .patch files for you. You probably want to add this to your .gitignore. Now to sending the patches.

$ git send-email -your-patches-

Before running this command, you will need to edit your .git/config file and fill out your details. After sending out the patches, you still have the .patch files hanging around, if you did not store them in a separate directory. What I do after this is run

$ rm -rf -your-patches-

This will simply get rid of the files for you. To apply patches by other developers, you simply run

$ git am name-of-patch.eml

This for a patch in email format. For patches in text format, use git apply.

There is the summary of some of the commands you'll find yourself using. Of course, there is a lot more and this no complete git documentation. I hope it helps someone starting out in open source. I am also pretty new to git, so feel free to leave comments with additions and corrections. :)