Edit June 6, 2012: SCM Creator has been updated to not conflict with Redmine Git Hosting.
Oftentimes it’s beneficial to use more than one type of version control system within a given organization—SVN and Git being the two most popular. For the purposes of Redmine, the Redmine Git Hosting plugin is significantly more useful for handling git repositories, as it can manage public keys and is able to serve git files via the Smart HTTP Protocol. However, for the other repository types, it is generally easier to use the SCM Creator plugin, which allows the project manager to control repository creation and deletion.
Previously, these plugins were incompatible, both overriding the same method. Moreover, SCM Creator has compatibility issues with Redmine 1.4.0+. Thanks to the work of its creator, Andriy Lesyuk, however, both of these issues have been resolved!
- SCM Creator is installed in /usr/share/redmine/vendor/plugins/scm_creator, as per my guide here
- Redmine Git Hosting is installed in /usr/share/redmine/vendor/plugins/redmine_git_hosting, as per my guide here
- You want to use SCM Creator for everything that is not Git, and Redmine Git Hosting to handle all of the Git requests on its own
Configuring SCM Creator to work with Redmine Git Hosting
The configuration change here is fairly simple:
Edit the scm.yml file and add the following lines to it:
only_creator: false allow_add_local: true
so that the final file looks like this:
$ cat /usr/share/redmine/config/scm.yml production: auto_create: false deny_delete: false pre_create: /usr/local/bin/pre-create.sh post_create: /usr/local/bin/post-create.sh pre_delete: /usr/local/bin/pre-delete.sh post_delete: /usr/local/bin/post-delete.sh svn: path: /var/svn svnadmin: /usr/bin/svnadmin url: svn only_creator: false allow_add_local: true
and restart Apache. Everything should work properly after that!
View old version here: Expand
If you’ve been following along my other tutorials, you’ve probably noticed that the SCM Creator and Redmine Git Hosting plugins really just don’t want to cooperate one another. The conflict here is that they both override the same method (RepositoriesController#edit), so that while they appear to work on the surface (the correct menu shows up for each), the Git repository creation results in a 500 error message in AJAX, and the repository is not created. It turns out that, due to the internal implementations of these plugins, fixing this problem isn’t terribly hard, although it does involve editing two lines in the plugin files directly.
Fixing the Problem
Modifications to SCM Creator
Edit the /usr/share/redmine/vendor/plugins/scm_creator/lib/scm_repositories_controller_patch.rb and find the lines that look like this:
def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) base.class_eval do unloadable before_filter :delete_scm, :only => :destroy alias_method :edit, :edit_with_add end end
The important line here is the one contains “alias_method :edit, :edit_with_add”, as it’s what’s causing the conflict. Just comment it out for now—it’s used to add the repository in the plugin architecture, so we’ll need to make sure the edit_with_add method is called at some point.
It should now look like this:
def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) base.class_eval do unloadable before_filter :delete_scm, :only => :destroy # alias_method :edit, :edit_with_add end end
Modifications to Redmine Git Hosting
Once again, this is a one line change:
Edit /usr/share/redmine/vendor/plugins/redmine_git_hosting/lib/git_hosting/patches/repositories_controller_patch.rb and find the block that looks like this:
else edit_without_scm_settings end
Replace “edit_without_scm_settings” with “edit_with_add”, like so:
else # edit_without_scm_settings edit_with_add end
This ensures that there is now a process chain that first goes to the Redmine Git Hosting plugin, which will only activate if the repository is a Git repository or if the Git option is selected in the repository settings menu. If it is not a Git repository, it will forward the request on to SCM Creator’s edit_with_add method, which can handle all the other repository types.
I have only tested this fix with SVN, as I don’t use the other types of repositories, but there should be no conflicts: just make sure NOT to configure git in SCM Creator’s scm.yml, as that will cause further conflicts between the two systems.