Project

General

Profile

Actions

Feature #2110

closed

Fetch new changesets of a specific repository by script

Added by Markus Peter over 15 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
SCM
Target version:
-
Start date:
2008-10-29
Due date:
% Done:

0%

Estimated time:
Resolution:

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.

Actions #1

Updated by Eric Davis over 15 years ago

Try this

ruby script/runner -e production "Repository.find_by_url('http://my-url.com/repository').fetch_changesets" 
</pre
Actions #2

Updated by Markus Peter over 15 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.

Actions #3

Updated by Eric Davis over 15 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

Actions #4

Updated by Markus Peter over 15 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.

Actions #5

Updated by Toshi MARUYAMA over 13 years ago

  • Category set to SCM
Actions #6

Updated by Toshi MARUYAMA about 13 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF