diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7d815512..e22a761d 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -43,6 +43,7 @@ class RepositoriesController < ApplicationController @repository = Repository.factory(scm) @repository.is_default = @project.repository.nil? @repository.project = @project + render :layout => 'base_projects' end def newrepo @@ -50,48 +51,74 @@ class RepositoriesController < ApplicationController @repository = Repository.factory(scm) @repository.is_default = @project.repository.nil? @repository.project = @project + render :layout => 'base_projects' end + def fork + # system "htpasswd -mb "+@root_path+"user.passwd "+params[:repository][:identifier]+" "+@upasswd + # system "echo -e '"+params[:project_id]+"-"+params[:repository][:identifier]+"-write:"+ + # " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" + # system "git init --bare "+@project_path + # system "mv "+@project_path+"/hooks/post-update{.sample,}" + # system "chmod a+x"+@project_path+"/hooks/post-update" + # system "."+@project_path+"/hooks/post-update" + # system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + # " \n"+ + # "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+ + # " \n ' >>"+ + # @project_path+"/.htaccess" + render :action => "show" + end + def create + ##xianbo + @root_path="/home/pdl/redmine-2.3.2-0/apache2/" + @repository_name=params[:project_id]+"/"+params[:repository][:identifier]+".git" + @project_path=@root_path+"htdocs/"+@repository_name + @upasswd=params[:repository][:upassword] attrs = pickup_extra_info - if(params[:repository]["upassword"]) - params[:repository]["password"]=params[:repository]["upassword"] - if(params[:repository_scm]=="Subversion") - - params[:repository]["url"]='svn://10.0.47.245/'+params[:repository]["identifier"] - end - if(params[:repository_scm]=="Git") - params[:repository]["url"]=params[:repository]["identifier"]+'@10.0.47.245://'+params[:repository]["identifier"] - end + if(params[:repository][:upassword]!="") + params[:repository][:password]=params[:repository][:upassword] + if(params[:repository_scm]=="Git") + params[:repository][:url]=@project_path + end + # else + # render_error l(:error_scm_password_not_set); return + # render :action => 'newrepo' end + ###xianbo @repository = Repository.factory(params[:repository_scm]) @repository.safe_attributes = params[:repository] if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) end + #by xianbo + @repository.project = @project if request.post? && @repository.save - if(params[:repository]["upassword"]&¶ms[:repository_scm]=="Git") - system "htpasswd -mb /home/pdl/redmine-2.3.2-0/apache2/trustie2.passwd #{params[:repository]["identifier"]} #{params[:repository]["upassword"]}" - system "git init --bare /home/pdl/redmine-2.3.2-0/apache2/htdocs/#{params[:repository]["identifier"]}.git" - system "mv /home/pdl/redmine-2.3.2-0/apache2/htdocs/#{params[:repository]["identifier"]}.git/hooks/post-update{.sample,}" - system "./home/pdl/redmine-2.3.2-0/apache2/htdocs/#{params[:repository]["identifier"]}.git/hooks/post-update" - } - #system "C:/Users/ta/Desktop/modify.bat #{params[:repository]["identifier"]} #{params[:repository]["upassword"]}" - # system("mkdir c:/test/svn123") - # system("git init --bare c:/test/svn123/#{params[:repository]["identifier"]}") - - end - if(params[:repository]["upassword"]&¶ms[:repository_scm]=="Subversion") - system("svnadmin create c:/test/#{@project}/#{params[:repository]["identifier"]}") - end + if(params[:repository][:upassword]&¶ms[:repository_scm]=="Git") + system "htpasswd -mb "+@root_path+"user.passwd "+params[:repository][:identifier]+" "+@upasswd + system "echo -e '\n"+params[:project_id]+"-"+params[:repository][:identifier]+"-write:"+ + " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" + system "git init --bare "+@project_path + system "mv "+@project_path+"/hooks/post-update{.sample,}" + system "chmod a+x"+@project_path+"/hooks/post-update" + system "cd "+@project_path+"/hooks/" + system "./post-update" + system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + " \n"+ + "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+ + " \n ' >>"+ + @project_path+"/.htaccess" + + end redirect_to settings_project_path(@project, :tab => 'repositories') - else if(params[:repository]["upassword"]) - render :action => 'newrepo' - else - render :action => 'new' - end + else if(@upasswd) + render :action => 'newrepo', :layout =>'base_projects' + else + render :action => 'new', :layout =>'base_projects' end + end end def edit diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 75484a22..40962c68 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1005,8 +1005,17 @@ module ApplicationHelper if errors.any? html << "
\n" end html.html_safe @@ -1317,8 +1326,8 @@ module ApplicationHelper # end #added by william - def need_login - redirect_to signin_path + def get_fans_num(user) + user.watcher_users.count end #end end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index e100b131..264fac50 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -137,12 +137,14 @@ module RepositoriesHelper def scm_select_tag(repository) scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']] +#Modified by tanxianbo Redmine::Scm::Base.all.each do |scm| if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm) scm_options << ["Repository::#{scm}".constantize.scm_name, scm] - end - end + end + end +# Ended by tanxianbo select_tag('repository_scm', options_for_select(scm_options, repository.class.name.demodulize), :disabled => (repository && !repository.new_record?), @@ -161,7 +163,7 @@ module RepositoriesHelper content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => !repository.safe_attribute?('url')) + '
'.html_safe + - '(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') + + "".html_safe+"定义已有版本库URL路径,定义格式file:///, http://, https://, svn://, svn+[tunnelscheme]://"+"".html_safe) + content_tag('p', form.text_field(:login, :size => 30))+ content_tag('p', form.password_field( :password, :size => 30, :name => 'ignore', @@ -198,13 +200,13 @@ module RepositoriesHelper # end def git_field_tags(form, repository) - content_tag('p', form.text_field( - :url, :label => l(:field_path_to_repository), - :size => 60, :required => true, - :disabled => !repository.safe_attribute?('url') - ) + - '
'.html_safe + - l(:text_git_repository_note)) + + # content_tag('p', form.text_field( + # :url, :label => l(:field_path_to_repository), + # :size => 60, :required => true, + # :disabled => !repository.safe_attribute?('url') + # ) + + # '
'.html_safe + + # l(:text_git_repository_note)) + content_tag('p', form.select( :path_encoding, [nil] + Setting::ENCODINGS, :label => l(:field_scm_path_encoding) diff --git a/app/views/projects/settings/_repositories.html.erb b/app/views/projects/settings/_repositories.html.erb index 6b6f9a06..50dce4ce 100644 --- a/app/views/projects/settings/_repositories.html.erb +++ b/app/views/projects/settings/_repositories.html.erb @@ -1,3 +1,5 @@ +<% project_path_cut = 40 %> +<% ip = "222.247.54.100" %> <% if @project.repositories.any? %> @@ -5,7 +7,7 @@ - + @@ -18,15 +20,22 @@ - - + <%else %> + <% end %> + + <% end %> diff --git a/app/views/repositories/_form_create.html.erb b/app/views/repositories/_form_create.html.erb new file mode 100644 index 00000000..5135cb6d --- /dev/null +++ b/app/views/repositories/_form_create.html.erb @@ -0,0 +1,38 @@ + + + +<%= error_messages_for 'repository' %> + +
+ +

+<%= label_tag('repository_scm', l(:label_scm)) %> + + <%= select_tag('repository_scm', + options_for_select(["Git"],@repository.class.name.demodulize), + :data => {:remote => true, :method => 'get'})%> + +<% if @repository && ! @repository.class.scm_available %> + <%= l(:text_scm_command_not_available) %> +<% end %> +

+

<%= f.check_box :is_default, :label => :field_repository_is_default %>

+

<%= f.text_field :identifier, :required=>true, :disabled => @repository.identifier_frozen? %> +<% unless @repository.identifier_frozen? %> + <%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %> + <%= l(:text_repository_identifier_info).html_safe %> +<% end %>

+ +

<%= f.password_field :upassword, :required =>true, :label=> :field_password %>

+

<%= f.select(:path_encoding, [nil] + Setting::ENCODINGS, :label => l(:field_scm_path_encoding))%> + <%= l(:text_scm_path_encoding_note)%>

+
+

+ <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> + <%= link_to l(:button_cancel), settings_project_path(@project, :tab => 'repositories') %> +

diff --git a/app/views/repositories/newrepo.html.erb b/app/views/repositories/newrepo.html.erb new file mode 100644 index 00000000..0461d576 --- /dev/null +++ b/app/views/repositories/newrepo.html.erb @@ -0,0 +1,6 @@ + +

<%= l(:label_repository_new_repos) %>

+<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form'} do |f| %> + <%= render :partial => 'form_create', :locals => {:f => f} %> + + <% end %> \ No newline at end of file diff --git a/app/views/repositories/newrepo.js.erb b/app/views/repositories/newrepo.js.erb new file mode 100644 index 00000000..a0d078ae --- /dev/null +++ b/app/views/repositories/newrepo.js.erb @@ -0,0 +1 @@ +$('#content').html('<%= escape_javascript(render :template => 'repositories/newrepo', :formats => [:html]) %>'); \ No newline at end of file
<%= l(:field_identifier) %> <%= l(:field_repository_is_default) %> <%= l(:label_scm) %><%= l(:label_repository) %><%= l(:label_repository_path) %>
<%= checked_image repository.is_default? %> <%=h repository.scm_name %><%=h repository.url %> - <% if User.current.allowed_to?(:manage_repository, @project) %> - <%= link_to(l(:label_user_plural), committers_repository_path(repository), - :class => 'icon icon-user') %> - <%= link_to(l(:button_edit), edit_repository_path(repository), - :class => 'icon icon-edit') %> - <%= delete_link repository_path(repository) %> + <%if repository.scm_name=="Git"%> + http://<%= repository.identifier%>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %><%=h repository.url %> + <% if repository.scm_name=="Subversion"%> + <%if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository), + :class => 'icon icon-user') %> + <%= link_to(l(:button_edit), edit_repository_path(repository), + :class => 'icon icon-edit') %> + <%= delete_link repository_path(repository) %> + <% end %> + <% end %>