Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.85 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1.  
  2. # See what a 'refactored' page looked like before you fucked it up
  3.  
  4. In your Rails/Sinatra/Whatever app when running in your development environment, expose a 'commit' parameter.
  5.  
  6. If that parameter is present, have your app serve the view as it was at that commit.  E.G.  http://localhost:3000/session/new&_commit=HEAD^.
  7.  
  8. You'll need to intercept whatever you need to in order to determine the file to render (dependent on framework), but ultimately you just need a call to Git like this to make it work:
  9.  
  10.     `git show #{params['_commit']}:#{path_to_view} > #{tmp_file}`
  11.  
  12. Then arrange for temp_file to handle the view rendering for this request.
  13.  
  14. In all fairness, for all but the simplest of apps, this is actually pretty tricky to do as you'll have partials, and helpers to contend with too.
  15.  
  16. But I've found it fairly helpful in a simple Sinatra app at work.