Feature #2110
closedFetch new changesets of a specific repository by script
0%
Description
As explained in the guide, the line
ruby script/runner "Repository.fetch_changesets" -e production
allows to periodically fetch all new changesets of all repositories.
It would be useful to be able to specify the name of the repository for which to fetch the changesets. That way, the script could be called in a post-commit hook and could fetch only the changesets of the repository which caused the post-commit hook to fire.
In a multi-project setup with numerous repositories it seems a waste of time and resources to check all repositories for new changesets every time a commit is made.
Ideally, one would be able to pass the url of the repository which usually is known to the post-commit handler. Redmine then would check whether there is a repository with the given url and call fetch_changesets of that repository only.
Updated by Eric Davis about 16 years ago
Try this
ruby script/runner -e production "Repository.find_by_url('http://my-url.com/repository').fetch_changesets" </pre
Updated by Markus Peter about 16 years ago
This didn't work, I got the following error:
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/commands/runner.rb:47: undefined method `fetch_changesets' for nil:NilClass (NoMethodError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `eval' from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/commands/runner.rb:47 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from script/runner:3
As you can see, I'm running on windows, I have r1901 from the trunk, everything working fine.
Btw, where would I find the method find_by_url (I'm a ruby noob)? I've been searching all files but couldn't find it.
Updated by Eric Davis about 16 years ago
Markus Peter wrote:
This didn't work, I got the following error:
So your repository url wasn't found. I would double check that the url you are using matches the project url.
As you can see, I'm running on windows, I have r1901 from the trunk, everything working fine.
Btw, where would I find the method find_by_url (I'm a ruby noob)? I've been searching all files but couldn't find it.
find_by_url
is a dynamic finder. Ruby on Rails creates several find_by_xxx
based on the fields on an ActiveRecord class. url
is a field on the Repository so find_by_url
is asking "Get the the Repository where the url is xxxx". More details about dynamic finders
Updated by Markus Peter about 16 years ago
- Status changed from New to Resolved
Tried again, this time copy-pasting the url and it worked - I must have made a typo before... Thanks a lot!
This is very slow - 100% CPU for about 10-15 seconds, with mysql and svn repositories on the same box, even if there are no new revisions to import. Calling Repository.fetch_changesets (~25 repositories) takes only about 25-30 seconds. Activating auto-fetch and calling the repository web page is by far the fastest (less than 1 second).
Therefore I hesitate to call it from a post-commit hook. Calling the url /repositories/show/[project identifier] from a post-commit hook would be faster, but of course I do not have the project identifier, and calling that page needs authentication.
Thanks for the explications of dynamic finders, this seems a tremendously useful feature.
Updated by Toshi MARUYAMA over 13 years ago
- Status changed from Resolved to Closed