@repository = @project.repository
if !@repository
@repository = Repository.factory(params[:repository_scm])
- @repository.project = @project
+ @repository.project = @project if @repository
end
- if request.post?
+ if request.post? && @repository
@repository.attributes = params[:repository]
@repository.save
end
end
def scm_select_tag(repository)
- container = [[]]
- REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
+ scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
+ REDMINE_SUPPORTED_SCM.each do |scm|
+ scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
+ end
+
select_tag('repository_scm',
- options_for_select(container, repository.class.name.demodulize),
+ options_for_select(scm_options, repository.class.name.demodulize),
:disabled => (repository && !repository.new_record?),
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
)
belongs_to :project
has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
has_many :changes, :through => :changesets
-
+
+ # Checks if the SCM is enabled when creating a repository
+ validate_on_create { |r| r.errors.add(:type, :activerecord_error_invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
+
# Removes leading and trailing whitespace
def url=(arg)
write_attribute(:url, arg ? arg.to_s.strip : nil)
:class => 'icon icon-del') if @repository && !@repository.new_record? %>
</div>
-<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save)) %>
+<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %>
<% end %>
<p><label><%= l(:setting_sys_api_enabled) %></label>
<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
+<p><label><%= l(:setting_enabled_scm) %></label>
+<% REDMINE_SUPPORTED_SCM.each do |scm| -%>
+<%= check_box_tag 'settings[enabled_scm][]', scm, Setting.enabled_scm.include?(scm) %> <%= scm %>
+<% end -%>
+<%= hidden_field_tag 'settings[enabled_scm][]', '' %>
+</p>
+
<p><label><%= l(:setting_repositories_encodings) %></label>
<%= text_field_tag 'settings[repositories_encodings]', Setting.repositories_encodings, :size => 60 %><br /><em><%= l(:text_comma_separated) %></em></p>
</div>
feeds_limit:
format: int
default: 15
+enabled_scm:
+ serialized: true
+ default:
+ - Subversion
+ - Darcs
+ - Mercurial
+ - Cvs
+ - Bazaar
+ - Git
autofetch_changesets:
default: 1
sys_api_enabled:
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
setting_user_format: Users display format
setting_activity_days_default: Days displayed on project activity
setting_display_subprojects_issues: Display subprojects issues on main projects by default
+setting_enabled_scm: Enabled SCM
project_module_issue_tracking: Issue tracking
project_module_time_tracking: Time tracking
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
setting_user_format: Format d'affichage des utilisateurs
setting_activity_days_default: Nombre de jours affichés sur l'activité des projets
setting_display_subprojects_issues: Afficher par défaut les demandes des sous-projets sur les projets principaux
+setting_enabled_scm: SCM activés
project_module_issue_tracking: Suivi des demandes
project_module_time_tracking: Suivi du temps passé
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d feladat határidős az elkövetkező napokban"
text_user_wrote: '%s írta:'
label_duplicated_by: duplikálta
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
enumeration_issue_priorities: Sakssprioriteringer
enumeration_doc_categories: Dokument-kategorier
enumeration_activities: Aktiviteter (tidssporing)
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"\r
text_user_wrote: '%s wrote:'\r
label_duplicated_by: duplicated by\r
+setting_enabled_scm: Enabled SCM\r
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d назначенных на вас задач в ближайшие дни"
text_user_wrote: '%s написал:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
mail_subject_reminder: "%d issue(s) due in the next days"
text_user_wrote: '%s wrote:'
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤)
+setting_enabled_scm: Enabled SCM
enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪)
label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
assert_equal repository, project.repository\r
end
+ def test_should_not_create_with_disabled_scm
+ # disable Subversion
+ Setting.enabled_scm = ['Darcs', 'Git']
+ repository = Repository::Subversion.new(:project => Project.find(3), :url => "svn://localhost")
+ assert !repository.save
+ assert_equal :activerecord_error_invalid, repository.errors.on(:type)
+ end
+
def test_scan_changesets_for_issue_ids
# choosing a status to apply to fix issues
Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id