修改了版本库

This commit is contained in:
Administrator 2013-08-12 16:22:38 +08:00
parent b0c813df69
commit 57991b727a
7 changed files with 142 additions and 50 deletions

View File

@ -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 "+
# "<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
# "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+
# "</Limit> \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"]&&params[: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"]&&params[:repository_scm]=="Subversion")
system("svnadmin create c:/test/#{@project}/#{params[:repository]["identifier"]}")
end
if(params[:repository][:upassword]&&params[: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 "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+
"</Limit> \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

View File

@ -1005,8 +1005,17 @@ module ApplicationHelper
if errors.any?
html << "<div id='errorExplanation'><ul>\n"
errors.each do |error|
html << "<li>#{h error}</li>\n"
###by xianbo
if(error!="库路径 不能为空字符")
html << "<li>#{h error}</li>\n"
end
###xianbo
end
###by xianbo
if params[:repository][:upassword]==""
html << "<li>密码不能设置为空。</li>\n"
end
###xianbo
html << "</ul></div>\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

View File

@ -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')) +
'<br />'.html_safe +
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
"<em class='info'>".html_safe+"定义已有版本库URL路径定义格式file:///, http://, https://, svn://, svn+[tunnelscheme]://"+"</em>".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')
) +
'<br />'.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')
# ) +
# '<br />'.html_safe +
# l(:text_git_repository_note)) +
content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_scm_path_encoding)

View File

@ -1,3 +1,5 @@
<% project_path_cut = 40 %>
<% ip = "222.247.54.100" %><!--Added by tanxianbo For formatting project's path-->
<% if @project.repositories.any? %>
<table class="list">
<thead>
@ -5,7 +7,7 @@
<th><%= l(:field_identifier) %></th>
<th><%= l(:field_repository_is_default) %></th>
<th><%= l(:label_scm) %></th>
<th><%= l(:label_repository) %></th>
<th><%= l(:label_repository_path) %></th>
<th></th>
</tr>
</thead>
@ -18,15 +20,22 @@
</td>
<td align="center"><%= checked_image repository.is_default? %></td>
<td><%=h repository.scm_name %></td>
<td><%=h repository.url %></td>
<td class="buttons">
<% 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"%>
<td>http://<%= repository.identifier%>@<%= ip %><%=h repository.url.slice(project_path_cut, repository.url.length) %></td><!--Modified by tanxianbo-->
<%else %>
<td><%=h repository.url %></td>
<% end %>
<td class="buttons">
<% 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 %>
</td>
</tr>
<% end %>

View File

@ -0,0 +1,38 @@
<!-- #changed by xianbo tan -->
<style type="text/css">
.textbg{
background-color:gray;
border:none
}
</style>
<%= error_messages_for 'repository' %>
<div class="box tabular">
<p>
<%= label_tag('repository_scm', l(:label_scm)) %>
<!--Modified by tanxianbo-->
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<!--Ended by tanxianbo-->
<% if @repository && ! @repository.class.scm_available %>
<em class="info error"><%= l(:text_scm_command_not_available) %></em>
<% end %>
</p>
<p><%= f.check_box :is_default, :label => :field_repository_is_default %></p>
<p><%= f.text_field :identifier, :required=>true, :disabled => @repository.identifier_frozen? %>
<% unless @repository.identifier_frozen? %>
<em class="info"><%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %>
<%= l(:text_repository_identifier_info).html_safe %></em>
<% end %></p>
<!-- <p><%= f.text_field :url, :size => 60, :required => true,:readonly=>true, :class=>'textbg'%></p> -->
<p><%= f.password_field :upassword, :required =>true, :label=> :field_password %></p>
<p><%= f.select(:path_encoding, [nil] + Setting::ENCODINGS, :label => l(:field_scm_path_encoding))%>
<%= l(:text_scm_path_encoding_note)%></p>
</div>
<p>
<%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %>
<%= link_to l(:button_cancel), settings_project_path(@project, :tab => 'repositories') %>
</p>

View File

@ -0,0 +1,6 @@
<!-- new repository new by xianbo-->
<h3><%= l(:label_repository_new_repos) %></h3>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form'} do |f| %>
<%= render :partial => 'form_create', :locals => {:f => f} %>
<% end %>

View File

@ -0,0 +1 @@
$('#content').html('<%= escape_javascript(render :template => 'repositories/newrepo', :formats => [:html]) %>');