views:

40

answers:

3

I'm working on a project where I programmatically need to know when a URL has been changed by a developer, post or during deploy. The obvious answer may be to curl the URL one day, save the output, then curl again in x days and diff the two. That won't work in my case, as I'm only looking for changes the developer made. If the site is a blog, new comments, user submitted photos, etc would make that diff useless.

RoR example, using github. Let's assume I have access to the entire repository and all commit logs between iterations. Is there a way I could see that "/views/people/show.html.erb" was commited, then backtrack from there (maybe by inspecting routes.rb), to come up with the URL I can then hit via a browser?

A: 

You can check the log for a specific file by passing it as the last parameter to git log. For example,

$ git log -- app/views/people/show.html.erb

will only show the log of commits that touched show.html.erb in some way. For better output, you could fiddle with additional parameters to git log. I suppose from there, you could use rake routes or routes.rb to figure out the URLs you'd need to hit to generate your images.

mipadi
A: 

I'm not familiar with rails, but I'll assume that there's no easy way to analyze the code at any state and figure out a map that links all urls to pages/functions that participate in rendering them.

A practical solution would be for each developer to include in the log message a few special lines that indicate which url's his changes affect.

For instance:

!url: /sections/people/show

Then you can grep the log for !url: lines using git log --grep='!url:' and parse the output to gather the urls affected by each commit.

hasen j
+1  A: 
corprew
Nice idea. Run each commit through a standardized test environment and record the difference among the generated pages. As long as the test data has good coverage, you end up with a nice, automated “which pages does this commit change” detector.
Chris Johnsen