开发者

Determining URLs updated via a series of commit logs

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开发者_StackOverflow社区 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?


This is probably quite difficult in the general case. However, in the restricted cases where it does work (and isn't an np-completely-annoying problem), it will probably be much more useful if you think in terms of changesets rather than individual source files changing.

I did something similar to this for a project in the past, with a domain restricted to:

  • for a certain website,
  • with certain data loaded into it,
  • for a certain subset of the pages on that site

was there a difference between what was displayed between one changeset and the next as they were committed to the head. To do this, I used a test website/database and had a script that deployed and populated it. For each page in question, I took an md5 sum of what was displayed (along with some things like some referenced javascript, stylesheets and images.)

I mention this because this actually scales pretty well and may be what you're trying to do. It is especially easy to do with rails because of things like puppet, capistrano, or chef helping this process along.

I never bothered to figure out the mapping between particular files and particular urls, because it was difficult to figure that out for things like versioned libraries, gems, etc. it was easier to just have the process kick out a list of changed urls per developer commit and not worry about it on a per-file basis.

good luck!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜