feature #9137 Password-protected SVN repositories
* added login and password attributes on repositories * fixed svn calls (svn waiting for user input) git-svn-id: http://redmine.rubyforge.org/svn/trunk@319 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8cbb78bb1d
commit
7a20a4d32b
|
@ -23,6 +23,6 @@ class Repository < ActiveRecord::Base
|
||||||
@scm = nil
|
@scm = nil
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
@scm ||= SvnRepos::Base.new url
|
@scm ||= SvnRepos::Base.new url, login, password
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,9 +23,6 @@ module SvnRepos
|
||||||
end
|
end
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
@url = nil
|
|
||||||
@login = nil
|
|
||||||
@password = nil
|
|
||||||
|
|
||||||
def initialize(url, login=nil, password=nil)
|
def initialize(url, login=nil, password=nil)
|
||||||
@url = url
|
@url = url
|
||||||
|
@ -47,6 +44,7 @@ module SvnRepos
|
||||||
identifier = 'HEAD' unless identifier and identifier > 0
|
identifier = 'HEAD' unless identifier and identifier > 0
|
||||||
entries = Entries.new
|
entries = Entries.new
|
||||||
cmd = "svn list --xml #{target(path)}@#{identifier}"
|
cmd = "svn list --xml #{target(path)}@#{identifier}"
|
||||||
|
cmd << " --username #{@login} --password #{@password}" if @login
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
begin
|
begin
|
||||||
doc = REXML::Document.new(io)
|
doc = REXML::Document.new(io)
|
||||||
|
@ -76,8 +74,9 @@ module SvnRepos
|
||||||
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
|
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
|
||||||
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
||||||
revisions = Revisions.new
|
revisions = Revisions.new
|
||||||
cmd = "svn log --xml -r #{identifier_from}:#{identifier_to} "
|
cmd = "svn log --xml -r #{identifier_from}:#{identifier_to}"
|
||||||
cmd << "--verbose " if options[:with_paths]
|
cmd << " --username #{@login} --password #{@password}" if @login
|
||||||
|
cmd << " --verbose " if options[:with_paths]
|
||||||
cmd << target(path)
|
cmd << target(path)
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
begin
|
begin
|
||||||
|
@ -118,6 +117,7 @@ module SvnRepos
|
||||||
cmd << "#{identifier_to}:"
|
cmd << "#{identifier_to}:"
|
||||||
cmd << "#{identifier_from}"
|
cmd << "#{identifier_from}"
|
||||||
cmd << "#{target(path)}@#{identifier_from}"
|
cmd << "#{target(path)}@#{identifier_from}"
|
||||||
|
cmd << " --username #{@login} --password #{@password}" if @login
|
||||||
diff = []
|
diff = []
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
|
@ -133,6 +133,7 @@ module SvnRepos
|
||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
||||||
cmd = "svn cat #{target(path)}@#{identifier}"
|
cmd = "svn cat #{target(path)}@#{identifier}"
|
||||||
|
cmd << " --username #{@login} --password #{@password}" if @login
|
||||||
cat = nil
|
cat = nil
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
cat = io.read
|
cat = io.read
|
||||||
|
@ -154,7 +155,8 @@ module SvnRepos
|
||||||
|
|
||||||
def shellout(cmd, &block)
|
def shellout(cmd, &block)
|
||||||
logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
|
logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
|
||||||
IO.popen(cmd) do |io|
|
IO.popen(cmd, "r+") do |io|
|
||||||
|
io.close_write
|
||||||
block.call(io) if block_given?
|
block.call(io) if block_given?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
<div id="repository">
|
<div id="repository">
|
||||||
<% fields_for :repository, @project.repository, { :builder => TabularFormBuilder, :lang => current_language} do |repository| %>
|
<% fields_for :repository, @project.repository, { :builder => TabularFormBuilder, :lang => current_language} do |repository| %>
|
||||||
<p><%= repository.text_field :url, :size => 60, :required => true %><br />(http://, https://, svn://, file:///)</p>
|
<p><%= repository.text_field :url, :size => 60, :required => true %><br />(http://, https://, svn://, file:///)</p>
|
||||||
|
<p><%= repository.text_field :login, :size => 30 %></p>
|
||||||
|
<p><%= repository.password_field :password, :size => 30 %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>
|
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class AddRepositoryLoginAndPassword < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :repositories, :login, :string, :limit => 60, :default => ""
|
||||||
|
add_column :repositories, :password, :string, :limit => 60, :default => ""
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :repositories, :login
|
||||||
|
remove_column :repositories, :password
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue