|
|
|
@ -76,6 +76,8 @@ class RepositoriesController < ApplicationController
|
|
|
|
|
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
|
|
|
|
|
@project_path=@root_path+"htdocs/"+@repository_name
|
|
|
|
|
@repository_tag=params[:repository][:upassword]
|
|
|
|
|
@repo_name=User.current.login.to_s+"-"+params[:repository][:identifier]
|
|
|
|
|
@middle=User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"
|
|
|
|
|
attrs = pickup_extra_info
|
|
|
|
|
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
|
|
|
|
params[:repository][:url]=@project_path
|
|
|
|
@ -91,23 +93,19 @@ class RepositoriesController < ApplicationController
|
|
|
|
|
@repository.project = @project
|
|
|
|
|
if request.post? && @repository.save
|
|
|
|
|
if(params[:repository_scm]=="Git")
|
|
|
|
|
system "htpasswd -mb "+@root_path+"user.passwd "+User.current.login.to_s+" "+@repository_tag
|
|
|
|
|
system "echo -e '\n"+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"+
|
|
|
|
|
" "+User.current.login.to_s+"' >> "+@root_path+"group.passwd"
|
|
|
|
|
system "htpasswd -mb "+@root_path+" "+@repo_name+" "+@repository_tag
|
|
|
|
|
system "echo -e '\n"+@repo_name+"-write:"+
|
|
|
|
|
" "+@repo_name+"' >> "+@root_path+"group.passwd"
|
|
|
|
|
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
|
|
|
|
|
system "git init --bare "+@project_path
|
|
|
|
|
system "mv "+@project_path+"/hooks/post-update{.sample,}"
|
|
|
|
|
system "chmod a+x "+@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 "+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write \n "+
|
|
|
|
|
"Require group "+@repo_name+"-write \n "+
|
|
|
|
|
"</Limit> \n ' >> "+
|
|
|
|
|
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
|
|
|
|
|
|
|
|
|
puts "before ======================================================================"
|
|
|
|
|
puts system "cd "+@project_path+" ;git update-server-info"
|
|
|
|
|
flag = system "cd "+@project_path+" ;git update-server-info"
|
|
|
|
|
puts "after flag:#{flag} ======================================================================"
|
|
|
|
|
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
|
|
|
|
flag = system "cd "+@project_path+" ;git update-server-info"
|
|
|
|
|
@repository.update_attributes(:login => User.current.login.to_s)
|
|
|
|
|
end
|
|
|
|
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
|
|
|
@ -170,11 +168,10 @@ class RepositoriesController < ApplicationController
|
|
|
|
|
@repository_name=User.current.login.to_s+"/"+@repository.identifier.to_s+".git"
|
|
|
|
|
@repository.destroy if request.delete?
|
|
|
|
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
|
|
|
|
if(@repository.type=="Repository::Git")
|
|
|
|
|
puts "before destroy system cmd ======================================="
|
|
|
|
|
puts "rm -r "+@root_path+@repository_name
|
|
|
|
|
flag = system "rm -r "+@root_path+"htdocs/"+@repository_name
|
|
|
|
|
puts "after destroy system cmd :#{flag} ======================================="
|
|
|
|
|
if(@repository.type=="Repository::Git")
|
|
|
|
|
system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd"
|
|
|
|
|
system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd"
|
|
|
|
|
system "rm -r "+@root_path+"htdocs/"+@repository_name
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|