Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created November 11, 2010 16:20
Show Gist options
  • Save rwaldron/672714 to your computer and use it in GitHub Desktop.
Save rwaldron/672714 to your computer and use it in GitHub Desktop.
# Tips for jQuery Bug Patching
# There are some assumptions made here, one being that you're
# set up with a LAMP or MAMP running a "localhost" http server.
# If you do not have git installed, check these out:
# - http://help.github.com/linux-git-installation/
# - http://help.github.com/mac-git-installation/
# cd to your web root directory, whatever that might be:
$ cd /path/to/your/www/root/
# clone your jQuery fork to work locally
$ git clone [email protected]:username/jquery.git
# cd to the newly created dir jquery/
$ cd jquery
$ git remote add upstream git://github.com/jquery/jquery.git
$ git pull upstream master
$ make
$ firefox http://localhost/jquery/test
#BAM!
# Additional Stuff That IS Really Useful:
# Overcome your emotional attachment to your local jquery repo
$ git pull upstream master --force
# or just...
$ git pull upstream master
# Never write your patches to the master branch - it gets messy.
# Writing patches: Use a branch!
# XXXX = the ticket #
$ git branch bug_XXXX
$ git checkout bug_XXXX
# or...
$ git checkout -b bug_XXXX
#now you're on branch: bug_XXXX
# Open up files and make changes
# Open up the corresponding /test/unit/file.js and add unit tests
# Run http://localhost/jquery/test --> ALL TESTS MUST PASS **
# Once you're satisfied with your patch...
# stage the files to be tracked:
$ git add filename
# (I recommend NEVER, EVER using "git add . ")
$ git commit -m "Bug #XXXX; Brief description of fix"
# this pushes your newly created branch and the commits to your github fork
$ git push origin -u bug_XXXX
# Test suite tips...
# During the process writing you patch and your ticket, you can narrow
# the test suite down to the module you are testing by either double clicking
# the title of the test or appending it to the url. The follwing examples
# assume you're working on a local repo, hosted on your localhost server.
# for example:
http://localhost/jquery/test/?css:
# this will only run the "css" module tests. This will significantly
# speed up your time spent debugging.
# ALWAYS RUN THE FULL SUITE BEFORE COMMITTING AND PUSHING A PATCH!!!
# jQuery supports the following:
** Supported Browsers :
Chrome Current-1
Safari 3+
Firefox 3.0.12, 3.5, 3.6, 4
IE 6+ (Will not fix IE9 bugs until real release)
Opera 10.60+
@cowboy
Copy link

cowboy commented Nov 23, 2010

+1

@paulirish
Copy link

git clone ==> git clone --recursive. It auto initializes & updates submodules.

@paulirish
Copy link

oh wait. no submodules. nvm. ohwell.. #protip anyways.

@cowboy
Copy link

cowboy commented Dec 27, 2010

I forgot to create a new feature branch before issuing a pull request, so my fork's master actually has a handful of commits that haven't been merged. They might never be, who knows. If you've run into this issue and want to create a new feature branch in order to issue a new pull request, without deleting your repo and doing things all over again, you should be able to follow these steps.

First, you need to find the SHA of a commit that predates any of your unmerged commits. Do this, and look for the most recent commit that isn't yours. That's probably the one you want. The SHA is the 7 characters of nonsense at the beginning of that line.

git checkout master && git log --pretty=format:"%h %ae, %ar: %s"

After you have the SHA, it's a simple matter of creating your branch from that commit, then pulling from the upstream repo. This assumes you've already defined upstream as a remote.

git checkout -b your_branch commit_sha && git pull upstream master

At this point, everything in your new branch should be up-to-date and ready for editing.

@peol
Copy link

peol commented Dec 27, 2010

git status will also display what branch you're currently working on.

Nice how to/help list, really useful.

@addyosmani
Copy link

Really awesome work putting this together.

@StevenBlack
Copy link

This really helps in understanding the process. Thanks for sharing.

@jancel
Copy link

jancel commented Feb 15, 2011

If you are running into an issue using the python -m SimpleHTTPServer (on Mac) with ajax: jQuery.ajax() modules then you may not have php installed. I alleviated this setting up MAMP and using the webroot supplied.

@cowboy
Copy link

cowboy commented Mar 31, 2011

You can use brew install node to install node, too.

@mathiasbynens
Copy link

You could use servedir to set up the localhost HTTP server, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment