Skip to content

Instantly share code, notes, and snippets.

@rtomayko
Created February 13, 2015 04:10
Show Gist options
  • Save rtomayko/4701b2750e8e7b9d3a2e to your computer and use it in GitHub Desktop.
Save rtomayko/4701b2750e8e7b9d3a2e to your computer and use it in GitHub Desktop.
Apply a patch to a bundle installed gem (not for the faint of heart)
#!/bin/sh
#/ Usage: gem-apply <gem> <patchfile
#/ Apply a patch to a locally installed gem.
#/
#/ Example:
#/ % curl https://github.com/jekyll/jekyll/pull/3452.patch | gem-apply jekyll
#/ patching file lib/jekyll/commands/serve.rb
#/ Hunk #1 succeeded at 39 (offset -1 lines).
#/ Hunk #2 succeeded at 125 (offset -6 lines).
#/ patching file lib/jekyll/commands/serve.rb
#/ Hunk #1 succeeded at 39 (offset -1 lines).
#/ Hunk #2 succeeded at 94 (offset -5 lines).
#/ Hunk #3 succeeded at 140 (offset -6 lines).
set -e
# Find location of gem and apply patch.
gemroot=$(bundle show "$1")
patch -d "$gemroot" -b -p1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment