Friday, November 25, 2011

Diff and Patch Rails Gems

Recently I built a gem for rails called wepay-rails. I cloned a copy of it locally so that I can work on it. Eventually though, I wanted to test it with my rails app and make changes to the gem code. So I then put it in my vendor/gems directory while I developed it. The problem I was running into though was making sure that the changes I was making in my vendor-ed version made it into my cloned version. It was a hassle to remember all the changes and make sure that the code moved across ok. I found the solution to this problem: Diff and Patch.

Here are some steps to create a patch from the vendor-ed gem and apply it to the cloned gem for release:

[adamthedev@localhost ~]$ diff -rc cloned_gem_directory/ updated_vendored_gem_directory/ > patchfile.patch

[adamthedev@localhost ~]$ patch -p0 -i patchfile.patch

That's it! Release the cloned gem!

No comments:

Post a Comment