diff --git a/app/assets/javascripts/settings.js.erb b/app/assets/javascripts/settings.js.erb
index b275eb3f68..0bd046cc73 100644
--- a/app/assets/javascripts/settings.js.erb
+++ b/app/assets/javascripts/settings.js.erb
@@ -27,8 +27,18 @@ See doc/COPYRIGHT.rdoc for more details.
++#%>
-jQuery(document).ready(function($) {
- $('#settings_session_ttl_enabled').on('change', function(){
- $('#settings_session_ttl_container').toggle($(this).is(':checked'));
- }).trigger('change');
-});
+(function($) {
+ $(function() {
+
+ $('#settings_session_ttl_enabled').on('change', function(){
+ $('#settings_session_ttl_container').toggle($(this).is(':checked'));
+ }).trigger('change');
+
+ $('#settings_repositories_automatic_managed_repos').change(function() {
+ var checked = this.checked;
+ $('#settings_repositories_automatic_managed_vendor').prop('disabled', function() {
+ return !checked;
+ })
+ });
+ });
+}(jQuery));
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index acc0a69e8a..8095000f3f 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -45,8 +45,8 @@ class RepositoriesController < ApplicationController
default_search_scope :changesets
before_filter :find_project_by_project_id
- before_filter :find_repository, except: [:edit, :update, :create, :destroy, :destroy_info]
before_filter :authorize
+ before_filter :find_repository, except: [:edit, :update, :create, :destroy, :destroy_info]
accept_key_auth :revisions
rescue_from OpenProject::Scm::Exceptions::ScmError, with: :show_error_command_failed
diff --git a/app/models/enabled_module.rb b/app/models/enabled_module.rb
index 8aa4b23e6d..2f34af0f07 100644
--- a/app/models/enabled_module.rb
+++ b/app/models/enabled_module.rb
@@ -47,6 +47,23 @@ class EnabledModule < ActiveRecord::Base
if project && project.wiki.nil?
Wiki.create(project: project, start_page: 'Wiki')
end
+ when 'repository'
+ if project &&
+ project.repository.nil? &&
+ Setting.repositories_automatic_managed_repos?
+ create_managed_repository
+ end
end
end
+
+ def create_managed_repository
+ params = {
+ scm_vendor: Setting.repositories_automatic_managed_vendor,
+ scm_type: Repository.managed_type
+ }
+
+ service = Scm::RepositoryFactoryService.new(project,
+ ActionController::Parameters.new(params))
+ service.build_and_save
+ end
end
diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb
index 65275ad378..4f1797699b 100644
--- a/app/views/settings/_repositories.html.erb
+++ b/app/views/settings/_repositories.html.erb
@@ -51,6 +51,23 @@ See doc/COPYRIGHT.rdoc for more details.
<%= setting_text_field :repository_log_display_limit, :size => 6 %>
<%= setting_check_box :repository_authentication_caching_enabled %>
+