Mozilla Bug Process using Git

With OSD700 now under way and many of the students in our class working on various sections of the mozilla code base I figured it would be helpful to give everyone a few pointers and a brief explanation of how to go about this.

Typical work flow might be like this:

  1. Get a bug to work on. Seems dumb to put but hear me out. With Bugzilla you aren’t able to just grab bugs as you please as a new user. You either need to get someone with the access rights to assign people or ask around about this. David Humphrey would obviously be a good place to start.
  2. Code Code Code Code Code Co…………. You get the point. Work on your bug. When you have it to point where either you feel it solves all the problems adequately or you just want some feed back proceed to point 3.
  3. At this point you have probably made many different commits. Maybe they were small changes, maybe they weren’t. Either way it’s best to rebase your code against master before doing a diff on your code to make the patch itself.
    1. Make a new temporary branch that is literally a duplicate of the one you have been working in.

      git checkout -b branchNameHere

    2. Until you get used to the process it’s best to take this precaution incase you mess things up (trust me, it hurts when you do).

    3. Go and update your master branch. You will want to make sure you have the most recent version of mozilla-central on your machine. Then return to the branch containing your changes.
    4. git rebase -i master


      This will allow you to rebase your code and, for what we want to do, combine all of our commits into ONE so we have only one nice patch file. After doing that you will wind up getting something like this on your screen:

    5. If you read the comment’s in blue you can see that there are options we can take while rebasing. What were are concerned with here is f, or fixup. We need one commit to still have p/pick beside it but every other commit needs to have f/fixup instead. For the one commit that will have pick beside it you need to ensure that it’s commit message is an appropriate one as it won’t be accepted otherwise by your reviewers. Something like the first commit in my example.
    6. After continuing you just need to finish off the rebase process and get ready to use a super duper awesome alias!
  4. Once you have finished rebasing you are on the home stretch. All it takes is one simple little git command and your are done. The only problem is this command isn’t available by default because it helps setup your patches to be in an acceptable format for Mozilla. Add this to your .gitconfig under [ alias ]:
    hgp = show --format=\"From: %an %n%s%n%b\" -U8

    Once you have this in your .gitconfig all it takes is a simple command to make a patch that will show the differences in your code compared to your local mozilla-central (Which should be up to date if you followed the instructions!):

    git hgp >place/file/in/whatever/directory/you/want/it/to/be/makeThisAMeaningFulNameForYourBug.patch
    
    For Example:
    
    git hgp >~/Desktop/bug698384.patch
    
  5. Woot! Now you just need to upload it to your bug, set it for review? and then who is going to review it! Wait, how do you know who should/could review it? Fear not! This should help you. If it doesn’t well, ask Humph if all else fails. Or #developers.

One final note. If your work ever requires you to use git mv on any of your files (maybe it needs to move to a different spot or you need to rename it completely) you will want to add this to your .gitconfig:

[diff]
  renames = copy

This will help ensure your patches are in an acceptable format for Mozilla.

Hope this helps!

Advertisements

One response to “Mozilla Bug Process using Git

  1. Pingback: OSD700 Release post 1 « Chris De Cairos

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: