summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-09 18:03:31 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-09 18:03:31 +0000
commit7a20a4d32b718f803aa4e3af286ab6a2275b8b6f (patch)
tree6c8d7d0bf8c4b58cb4f6b7ac4d1b13840fa3890e /app
parent8cbb78bb1dd2926f1168573d3ec0c86ea459f8f0 (diff)
downloadredmine-7a20a4d32b718f803aa4e3af286ab6a2275b8b6f.tar.gz
redmine-7a20a4d32b718f803aa4e3af286ab6a2275b8b6f.zip
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
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/svn_repos.rb14
-rw-r--r--app/views/projects/_form.rhtml2
3 files changed, 11 insertions, 7 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 29e87584f..d6e0e11aa 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -23,6 +23,6 @@ class Repository < ActiveRecord::Base
@scm = nil
def scm
- @scm ||= SvnRepos::Base.new url
+ @scm ||= SvnRepos::Base.new url, login, password
end
end
diff --git a/app/models/svn_repos.rb b/app/models/svn_repos.rb
index 7c6f5e01a..aed9f1b58 100644
--- a/app/models/svn_repos.rb
+++ b/app/models/svn_repos.rb
@@ -23,9 +23,6 @@ module SvnRepos
end
class Base
- @url = nil
- @login = nil
- @password = nil
def initialize(url, login=nil, password=nil)
@url = url
@@ -47,6 +44,7 @@ module SvnRepos
identifier = 'HEAD' unless identifier and identifier > 0
entries = Entries.new
cmd = "svn list --xml #{target(path)}@#{identifier}"
+ cmd << " --username #{@login} --password #{@password}" if @login
shellout(cmd) do |io|
begin
doc = REXML::Document.new(io)
@@ -76,8 +74,9 @@ module SvnRepos
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
revisions = Revisions.new
- cmd = "svn log --xml -r #{identifier_from}:#{identifier_to} "
- cmd << "--verbose " if options[:with_paths]
+ cmd = "svn log --xml -r #{identifier_from}:#{identifier_to}"
+ cmd << " --username #{@login} --password #{@password}" if @login
+ cmd << " --verbose " if options[:with_paths]
cmd << target(path)
shellout(cmd) do |io|
begin
@@ -118,6 +117,7 @@ module SvnRepos
cmd << "#{identifier_to}:"
cmd << "#{identifier_from}"
cmd << "#{target(path)}@#{identifier_from}"
+ cmd << " --username #{@login} --password #{@password}" if @login
diff = []
shellout(cmd) do |io|
io.each_line do |line|
@@ -133,6 +133,7 @@ module SvnRepos
def cat(path, identifier=nil)
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
cmd = "svn cat #{target(path)}@#{identifier}"
+ cmd << " --username #{@login} --password #{@password}" if @login
cat = nil
shellout(cmd) do |io|
cat = io.read
@@ -154,7 +155,8 @@ module SvnRepos
def shellout(cmd, &block)
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?
end
end
diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml
index 14c7a26ee..2191e9fa3 100644
--- a/app/views/projects/_form.rhtml
+++ b/app/views/projects/_form.rhtml
@@ -31,6 +31,8 @@
<div id="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 :login, :size => 30 %></p>
+<p><%= repository.password_field :password, :size => 30 %></p>
<% end %>
</div>
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>