Feature #1837 ยป autocreate_repo.patch
| app/controllers/repositories_controller.rb (working copy) | ||
|---|---|---|
|
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||
|
|
||
|
def edit
|
||
|
logger.debug("In RepositoryController.edit")
|
||
|
@repository = @project.repository
|
||
|
if !@repository
|
||
|
@repository = Repository.factory(params[:repository_scm])
|
||
|
@repository.project = @project if @repository
|
||
|
end
|
||
|
if request.post? && @repository
|
||
|
@repository.attributes = params[:repository]
|
||
|
url = login = password = nil
|
||
|
repo_script_success = true
|
||
|
if @repository.url != params[:repository][:url]
|
||
|
#repo url has changed. Call the auto_create_repo script....
|
||
|
if (Setting[:auto_create_repo] != 0) && (Setting[:autorepo_scriptpath] != ""):
|
||
|
logger.debug("Repository URL changed, running auto_create_repo script")
|
||
|
script = Setting[:autorepo_scriptpath]
|
||
|
id = @project.identifier
|
||
|
scm = params[:repository_scm]
|
||
|
url = params[:repository][:url]
|
||
|
begin
|
||
|
File.open("#{script}") #check if the script exists
|
||
|
IO.popen("#{script} #{scm} #{id}") { |p|
|
||
|
ret = p.gets
|
||
|
ret = ret.strip.split
|
||
|
if $? && $?.exitstatus != 0
|
||
|
repo_script_success = false
|
||
|
end
|
||
|
if ret.length == 3:
|
||
|
url, login, password = ret
|
||
|
else
|
||
|
url = ret
|
||
|
end
|
||
|
}
|
||
|
rescue Errno::ENOENT => e
|
||
|
logger.info("Script #{Setting[:autorepo_scriptpath]} for creating repository for project #{id} not found: #{e}")
|
||
|
#TODO: catch more possible errors
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
attrs = params[:repository]
|
||
|
if repo_script_success
|
||
|
attrs['url'] = url.to_s.strip
|
||
|
attrs['login'] = login.to_s.strip
|
||
|
attrs['password'] = password.to_s.strip
|
||
|
end
|
||
|
@repository.attributes = attrs
|
||
|
@repository.save
|
||
|
end
|
||
|
render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'}
|
||
| app/views/settings/_repositories.rhtml (working copy) | ||
|---|---|---|
|
<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_auto_create_repo) %></label>
|
||
|
<%= check_box_tag 'settings[auto_create_repo]', 1, Setting.auto_create_repo?%><%= hidden_field_tag 'settings[auto_create_repo]', 0 %></p>
|
||
|
<p><label><%= l(:setting_autorepo_scriptpath) %></label>
|
||
|
<%= text_field_tag 'settings[autorepo_scriptpath]', Setting.autorepo_scriptpath, :size=>60 %>
|
||
|
<br /><em><%= l(:text_autorepo_explain) %>
|
||
|
</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 %>
|
||
| lang/en.yml (working copy) | ||
|---|---|---|
|
setting_feeds_limit: Feed content limit
|
||
|
setting_default_projects_public: New projects are public by default
|
||
|
setting_autofetch_changesets: Autofetch commits
|
||
|
setting_auto_create_repo: Automatically create repository
|
||
|
setting_autorepo_scriptpath: Absolute path to script for creating repository
|
||
|
setting_sys_api_enabled: Enable WS for repository management
|
||
|
setting_commit_ref_keywords: Referencing keywords
|
||
|
setting_commit_fix_keywords: Fixing keywords
|
||
| ... | ... | |
|
text_enumeration_destroy_question: '%d objects are assigned to this value.'
|
||
|
text_enumeration_category_reassign_to: 'Reassign them to this value:'
|
||
|
text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
|
||
|
text_autorepo_explain: "The script will receive the following parameters: SCM type (e.g. Subversion), project identifier. It sets the repository URL and username and password (if applicable)."
|
||
|
default_role_manager: Manager
|
||
|
default_role_developper: Developer
|
||
|
default_role_reporter: Reporter
|
||