scm_patch_2.diff
app/controllers/#download_svn_revision_controller.rb# | ||
---|---|---|
1 |
class DownloadSvnRevisionController < ApplicationController |
|
2 |
unloadable |
|
3 | ||
4 |
before_filter :require_login |
|
5 |
before_filter :set_repository_variable |
|
6 |
before_filter :set_project_variable |
|
7 |
before_filter :can_download_svn_revision |
|
8 | ||
9 |
#helper :git_hosting |
|
10 |
def user_allowed_to_svn(permission, project) |
|
11 |
if project.active? |
|
12 |
return User.current.allowed_to?(permission, project) |
|
13 |
else |
|
14 |
return User.current.allowed_to?(permission, nil, :global => true) |
|
15 |
end |
|
16 |
end |
|
17 | ||
18 | ||
19 |
def index |
|
20 |
commit = nil |
|
21 |
format = params[:download_format] |
|
22 | ||
23 |
if !params[:rev] |
|
24 |
rev = "master" |
|
25 |
else |
|
26 |
rev = params[:rev] |
|
27 |
end |
|
28 | ||
29 |
if( |
|
30 |
project_name = @repository.name.to_s.parameterize.to_s |
|
31 | ||
32 |
cmd_args = "" |
|
33 | ||
34 |
case format |
|
35 |
when 'tar' then |
|
36 |
extension = 'tar' |
|
37 |
content_type = 'application/x-tar' |
|
38 |
cmd_args << "tar -cvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
39 |
when 'tar.gz' then |
|
40 |
extension = 'tar.gz' |
|
41 |
content_type = 'application/x-gzip' |
|
42 |
cmd_args << "tar -zcvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
43 |
when 'zip' then |
|
44 |
extension = 'zip' |
|
45 |
content_type = 'application/x-zip' |
|
46 |
cmd_args << "zip -r #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
47 |
end |
|
48 | ||
49 |
#begin |
|
50 |
#system("echo '#{@repository.url} #{project_name}-#{rev}.#{extension}' > log/logging.log") |
|
51 |
system("svn export #{@repository.url} #{project_name}-#{rev}; #{cmd_args}") |
|
52 |
content = "#{project_name}-#{rev}.#{extension}" |
|
53 |
#rescue => e |
|
54 |
#flash.now[:error] = l(:git_archive_timeout, :timeout => e.message) |
|
55 |
# render_404 |
|
56 |
#return |
|
57 |
#end |
|
58 |
if(File.file?("#{project_name}-#{rev}.#{extension}")) |
|
59 |
send_file(content, :filename => "#{project_name}-#{rev}.#{extension}", :type => content_type) |
|
60 |
end |
|
61 |
end |
|
62 | ||
63 | ||
64 |
private |
|
65 | ||
66 | ||
67 |
def can_download_svn_revision |
|
68 |
render_403 unless user_allowed_to_svn(:download_svn_revision, @project) |
|
69 |
end |
|
70 | ||
71 | ||
72 |
def set_repository_variable |
|
73 |
@repository = Repository.find_by_id(params[:repository_id]) |
|
74 |
if @repository.nil? |
|
75 |
render_404 |
|
76 |
end |
|
77 |
end |
|
78 | ||
79 | ||
80 |
def set_project_variable |
|
81 |
@project = @repository.project |
|
82 |
if @project.nil? |
|
83 |
render_404 |
|
84 |
end |
|
85 |
end |
|
86 | ||
87 |
end |
app/controllers/download_svn_revision_controller.rb | ||
---|---|---|
1 |
class DownloadSvnRevisionController < ApplicationController |
|
2 |
unloadable |
|
3 | ||
4 |
before_filter :require_login |
|
5 |
before_filter :set_repository_variable |
|
6 |
before_filter :set_project_variable |
|
7 |
before_filter :can_download_svn_revision |
|
8 | ||
9 |
#helper :git_hosting |
|
10 |
def user_allowed_to_svn(permission, project) |
|
11 |
if project.active? |
|
12 |
return User.current.allowed_to?(permission, project) |
|
13 |
else |
|
14 |
return User.current.allowed_to?(permission, nil, :global => true) |
|
15 |
end |
|
16 |
end |
|
17 | ||
18 | ||
19 |
def index |
|
20 |
commit = nil |
|
21 |
format = params[:download_format] |
|
22 | ||
23 |
if !params[:rev] |
|
24 |
rev = "master" |
|
25 |
else |
|
26 |
rev = params[:rev] |
|
27 |
end |
|
28 | ||
29 | ||
30 |
project_name = @repository.name.to_s.parameterize.to_s |
|
31 | ||
32 |
cmd_args = "" |
|
33 | ||
34 |
case format |
|
35 |
when 'tar' then |
|
36 |
extension = 'tar' |
|
37 |
content_type = 'application/x-tar' |
|
38 |
cmd_args << "tar -cvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
39 |
when 'tar.gz' then |
|
40 |
extension = 'tar.gz' |
|
41 |
content_type = 'application/x-gzip' |
|
42 |
cmd_args << "tar -zcvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
43 |
when 'zip' then |
|
44 |
extension = 'zip' |
|
45 |
content_type = 'application/x-zip' |
|
46 |
cmd_args << "zip -r #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
47 |
end |
|
48 | ||
49 |
#begin |
|
50 |
#system("echo '#{@repository.url} #{project_name}-#{rev}.#{extension}' > log/logging.log") |
|
51 |
system("svn export #{@repository.url} #{project_name}-#{rev}; #{cmd_args}") |
|
52 |
content = "#{project_name}-#{rev}.#{extension}" |
|
53 |
#rescue => e |
|
54 |
#flash.now[:error] = l(:git_archive_timeout, :timeout => e.message) |
|
55 |
# render_404 |
|
56 |
#return |
|
57 |
#end |
|
58 |
if(File.file?("#{project_name}-#{rev}.#{extension}")) |
|
59 |
send_file(content, :filename => "#{project_name}-#{rev}.#{extension}", :type => content_type) |
|
60 |
end |
|
61 |
end |
|
62 | ||
63 | ||
64 |
private |
|
65 | ||
66 | ||
67 |
def can_download_svn_revision |
|
68 |
render_403 unless user_allowed_to_svn(:download_svn_revision, @project) |
|
69 |
end |
|
70 | ||
71 | ||
72 |
def set_repository_variable |
|
73 |
@repository = Repository.find_by_id(params[:repository_id]) |
|
74 |
if @repository.nil? |
|
75 |
render_404 |
|
76 |
end |
|
77 |
end |
|
78 | ||
79 | ||
80 |
def set_project_variable |
|
81 |
@project = @repository.project |
|
82 |
if @project.nil? |
|
83 |
render_404 |
|
84 |
end |
|
85 |
end |
|
86 | ||
87 |
end |
app/controllers/download_svn_revision_controller.rb~ | ||
---|---|---|
1 |
class DownloadSvnRevisionController < ApplicationController |
|
2 |
unloadable |
|
3 | ||
4 |
before_filter :require_login |
|
5 |
before_filter :set_repository_variable |
|
6 |
before_filter :set_project_variable |
|
7 |
before_filter :can_download_svn_revision |
|
8 | ||
9 |
#helper :git_hosting |
|
10 |
def user_allowed_to(permission, project) |
|
11 |
if project.active? |
|
12 |
return User.current.allowed_to?(permission, project) |
|
13 |
else |
|
14 |
return User.current.allowed_to?(permission, nil, :global => true) |
|
15 |
end |
|
16 |
end |
|
17 | ||
18 | ||
19 |
def index |
|
20 |
commit = nil |
|
21 |
format = params[:download_format] |
|
22 | ||
23 |
if !params[:rev] |
|
24 |
rev = "master" |
|
25 |
else |
|
26 |
rev = params[:rev] |
|
27 |
end |
|
28 | ||
29 | ||
30 |
project_name = @repository.name.to_s.parameterize.to_s |
|
31 | ||
32 |
cmd_args = "" |
|
33 | ||
34 |
case format |
|
35 |
when 'tar' then |
|
36 |
extension = 'tar' |
|
37 |
content_type = 'application/x-tar' |
|
38 |
cmd_args << "tar -cvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
39 |
when 'tar.gz' then |
|
40 |
extension = 'tar.gz' |
|
41 |
content_type = 'application/x-gzip' |
|
42 |
cmd_args << "tar -zcvf #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
43 |
when 'zip' then |
|
44 |
extension = 'zip' |
|
45 |
content_type = 'application/x-zip' |
|
46 |
cmd_args << "zip -r #{project_name}-#{rev}.#{extension} #{project_name}-#{rev}" |
|
47 |
end |
|
48 | ||
49 |
#begin |
|
50 |
#system("echo '#{@repository.url} #{project_name}-#{rev}.#{extension}' > log/logging.log") |
|
51 |
system("svn export #{@repository.url} #{project_name}-#{rev}; #{cmd_args}") |
|
52 |
content = "#{project_name}-#{rev}.#{extension}" |
|
53 |
#rescue => e |
|
54 |
#flash.now[:error] = l(:git_archive_timeout, :timeout => e.message) |
|
55 |
# render_404 |
|
56 |
#return |
|
57 |
#end |
|
58 |
if(File.file?("#{project_name}-#{rev}.#{extension}")) |
|
59 |
send_file(content, :filename => "#{project_name}-#{rev}.#{extension}", :type => content_type) |
|
60 |
end |
|
61 |
end |
|
62 | ||
63 | ||
64 |
private |
|
65 | ||
66 | ||
67 |
def can_download_svn_revision |
|
68 |
render_403 unless view_context.user_allowed_to(:download_svn_revision, @project) |
|
69 |
end |
|
70 | ||
71 | ||
72 |
def set_repository_variable |
|
73 |
@repository = Repository.find_by_id(params[:repository_id]) |
|
74 |
if @repository.nil? |
|
75 |
render_404 |
|
76 |
end |
|
77 |
end |
|
78 | ||
79 | ||
80 |
def set_project_variable |
|
81 |
@project = @repository.project |
|
82 |
if @project.nil? |
|
83 |
render_404 |
|
84 |
end |
|
85 |
end |
|
86 | ||
87 |
end |
app/views/repositories/#_download_revision.erb# | ||
---|---|---|
1 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
2 |
<% if @repository.is_a?(Repository::Git) && RedmineGitolite::ConfigRedmine.get_setting(:download_revision_enabled, true) %> |
|
3 |
<% if (@project.active? && User.current.allowed_to?(:download_git_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_git_revision, nil, :global => true)) %> |
|
4 | ||
5 |
<div style="clear: both;"></div> |
|
6 | ||
7 |
<div id="git_hosting_download_buttons"> |
|
8 |
<ul> |
|
9 |
<li> |
|
10 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
11 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
12 |
:class => 'button' %> |
|
13 |
</li> |
|
14 | ||
15 |
<li> |
|
16 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
17 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
18 |
:class => 'button' %> |
|
19 |
</li> |
|
20 | ||
21 |
<li> |
|
22 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
23 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
24 |
:class => 'button' %> |
|
25 |
</li> |
|
26 |
</ul> |
|
27 |
</div> |
|
28 | ||
29 |
<% content_for :header_tags do %> |
|
30 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
31 |
<% end %> |
|
32 | ||
33 |
<% end %> |
|
34 |
<% end %> |
|
35 |
<% end %> |
|
36 | ||
37 | ||
38 |
<% if @repository.is_a?(Repository::Subversion)%> |
|
39 |
<% if (@project.active? && User.current.allowed_to?(:download_svn_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_svn_revision, nil, :global => true)) %> |
|
40 | ||
41 |
<div style="clear: both;"></div> |
|
42 | ||
43 |
<div id="svn_hosting_download_buttons"> |
|
44 |
<ul> |
|
45 |
<li> |
|
46 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
47 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
48 |
:class => 'button' %> |
|
49 |
</li> |
|
50 | ||
51 |
<li> |
|
52 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
53 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
54 |
:class => 'button' %> |
|
55 |
</li> |
|
56 | ||
57 |
<li> |
|
58 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
59 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
60 |
:class => 'button' %> |
|
61 |
</li> |
|
62 |
</ul> |
|
63 |
</div> |
|
64 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
65 |
<% content_for :header_tags do %> |
|
66 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
67 |
<% end %> |
|
68 |
<% end %> |
|
69 | ||
70 |
<% end %> |
|
71 |
<% end %> |
|
72 |
app/views/repositories/_download_revision.erb | ||
---|---|---|
1 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
2 |
<% if @repository.is_a?(Repository::Git) && RedmineGitolite::ConfigRedmine.get_setting(:download_revision_enabled, true) %> |
|
3 |
<% if (@project.active? && User.current.allowed_to?(:download_git_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_git_revision, nil, :global => true)) %> |
|
4 | ||
5 |
<div style="clear: both;"></div> |
|
6 | ||
7 |
<div id="git_hosting_download_buttons"> |
|
8 |
<ul> |
|
9 |
<li> |
|
10 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
11 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
12 |
:class => 'button' %> |
|
13 |
</li> |
|
14 | ||
15 |
<li> |
|
16 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
17 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
18 |
:class => 'button' %> |
|
19 |
</li> |
|
20 | ||
21 |
<li> |
|
22 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
23 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
24 |
:class => 'button' %> |
|
25 |
</li> |
|
26 |
</ul> |
|
27 |
</div> |
|
28 | ||
29 |
<% content_for :header_tags do %> |
|
30 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
31 |
<% end %> |
|
32 | ||
33 |
<% end %> |
|
34 |
<% end %> |
|
35 |
<% end %> |
|
36 | ||
37 | ||
38 |
<% if @repository.is_a?(Repository::Subversion)%> |
|
39 |
<% if (@project.active? && User.current.allowed_to?(:download_svn_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_svn_revision, nil, :global => true)) %> |
|
40 | ||
41 |
<div style="clear: both;"></div> |
|
42 | ||
43 |
<div id="svn_hosting_download_buttons"> |
|
44 |
<ul> |
|
45 |
<li> |
|
46 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
47 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
48 |
:class => 'button' %> |
|
49 |
</li> |
|
50 | ||
51 |
<li> |
|
52 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
53 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
54 |
:class => 'button' %> |
|
55 |
</li> |
|
56 | ||
57 |
<li> |
|
58 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
59 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
60 |
:class => 'button' %> |
|
61 |
</li> |
|
62 |
</ul> |
|
63 |
</div> |
|
64 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
65 |
<% content_for :header_tags do %> |
|
66 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
67 |
<% end %> |
|
68 |
<% end %> |
|
69 | ||
70 |
<% end %> |
|
71 |
<% end %> |
|
72 |
app/views/repositories/_download_revision.erb~ | ||
---|---|---|
1 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
2 |
<% if @repository.is_a?(Repository::Git) && RedmineGitolite::ConfigRedmine.get_setting(:download_revision_enabled, true) %> |
|
3 |
<% if (@project.active? && User.current.allowed_to?(:download_git_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_git_revision, nil, :global => true)) %> |
|
4 | ||
5 |
<div style="clear: both;"></div> |
|
6 | ||
7 |
<div id="git_hosting_download_buttons"> |
|
8 |
<ul> |
|
9 |
<li> |
|
10 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
11 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
12 |
:class => 'button' %> |
|
13 |
</li> |
|
14 | ||
15 |
<li> |
|
16 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
17 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
18 |
:class => 'button' %> |
|
19 |
</li> |
|
20 | ||
21 |
<li> |
|
22 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
23 |
download_git_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
24 |
:class => 'button' %> |
|
25 |
</li> |
|
26 |
</ul> |
|
27 |
</div> |
|
28 | ||
29 |
<% content_for :header_tags do %> |
|
30 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
31 |
<% end %> |
|
32 | ||
33 |
<% end %> |
|
34 |
<% end %> |
|
35 |
<% end %> |
|
36 | ||
37 | ||
38 |
<% if @repository.is_a?(Repository::Subversion)%> |
|
39 |
<% if (@project.active? && User.current.allowed_to?(:download_svn_revision, @project)) || (!@project.active? && User.current.allowed_to?(:download_svn_revision, nil, :global => true)) %> |
|
40 | ||
41 |
<div style="clear: both;"></div> |
|
42 | ||
43 |
<div id="svn_hosting_download_buttons"> |
|
44 |
<ul> |
|
45 |
<li> |
|
46 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar'), |
|
47 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar'), |
|
48 |
:class => 'button' %> |
|
49 |
</li> |
|
50 | ||
51 |
<li> |
|
52 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.tar.gz'), |
|
53 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'tar.gz'), |
|
54 |
:class => 'button' %> |
|
55 |
</li> |
|
56 | ||
57 |
<li> |
|
58 |
<%= link_to "<i class=\"fa fa-download\"></i>".html_safe + l(:label_download_format, :archive_format => '.zip'), |
|
59 |
download_svn_revision_path(@repository.id, :rev => @rev, :download_format => 'zip'), |
|
60 |
:class => 'button' %> |
|
61 |
</li> |
|
62 |
</ul> |
|
63 |
</div> |
|
64 | ||
65 |
<% content_for :header_tags do %> |
|
66 |
<%= stylesheet_link_tag 'font_awesome', :plugin => 'redmine_git_hosting' %> |
|
67 |
<% end %> |
|
68 | ||
69 |
<% end %> |
|
70 |
<% end %> |
|
71 |
app/views/repositories/_sidebar.html.erb | ||
---|---|---|
1 |
<% if Repository.respond_to?(:factory_with_git_hosting) %> |
|
2 |
<%= javascript_tag do %> |
|
3 |
$(document).ready(function() { |
|
4 |
$('#sidebar p').remove(); |
|
5 |
}); |
|
6 |
<% end %> |
|
7 | ||
8 | ||
9 | ||
10 |
<ul class="repository git"> |
|
11 |
<% @repositories.sort.each do |repo| %> |
|
12 |
<li class="repository git"><%= link_to h(repo.name), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, |
|
13 |
:class => [ 'repository', (repo == @repository ? 'selected' : ''), @repository.type.split('::')[1].downcase ].join(' ') %> |
|
14 |
</li> |
|
15 |
<% end %> |
|
16 |
</ul> |
|
17 | ||
18 |
<% if @repository.is_a?(Repository::Git) && RedmineGitolite::Config.get_setting(:show_repositories_url, true) %> |
|
19 |
<div class="git_hosting_urls"> |
|
20 |
<h3><%= l(:label_repository_access_url) %></h3> |
|
21 |
<%= render :partial => 'common/git_urls', :locals => {:repository => @repository} %> |
|
22 |
</div> |
|
23 |
<% end %> |
|
24 |
<% end %> |
|
25 | ||
26 |
<%= render :partial => 'repositories/download_revision' %> |
app/views/repositories/_sidebar.html.erb~ | ||
---|---|---|
1 |
<%= javascript_tag do %> |
|
2 |
$(document).ready(function() { |
|
3 |
$('#sidebar p').remove(); |
|
4 |
}); |
|
5 |
<% end %> |
|
6 | ||
7 | ||
8 | ||
9 |
<ul class="repository git"> |
|
10 |
<% @repositories.sort.each do |repo| %> |
|
11 |
<li class="repository git"><%= link_to h(repo.name), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, |
|
12 |
:class => [ 'repository', (repo == @repository ? 'selected' : ''), @repository.type.split('::')[1].downcase ].join(' ') %> |
|
13 |
</li> |
|
14 |
<% end %> |
|
15 |
</ul> |
|
16 | ||
17 |
<% if @repository.is_a?(Repository::Git) && RedmineGitolite::Config.get_setting(:show_repositories_url, true) %> |
|
18 |
<div class="git_hosting_urls"> |
|
19 |
<h3><%= l(:label_repository_access_url) %></h3> |
|
20 |
<%= render :partial => 'common/git_urls', :locals => {:repository => @repository} %> |
|
21 |
</div> |
|
22 |
<% end %> |
|
23 | ||
24 |
<%= render :partial => 'repositories/download_revision' %> |
config/routes.rb | ||
---|---|---|
1 |
match 'repositories/:repository_id/download_svn_revision', :to => 'download_svn_revision#index', |
|
2 |
:via => [:get], |
|
3 |
:as => 'download_svn_revision' |
init.rb | ||
---|---|---|
17 | 17 | |
18 | 18 |
require_dependency File.expand_path(File.join(File.dirname(__FILE__), 'app/models/repository_observer')) |
19 | 19 | |
20 | ||
20 | 21 |
Rails.logger.info 'Starting SCM Creator Plugin for Redmine' |
21 | 22 | |
22 | 23 |
ActiveRecord::Base.observers << RepositoryObserver |
... | ... | |
42 | 43 |
description 'Allows creating Subversion, Git, Mercurial, Bazaar and Github repositories within Redmine.' |
43 | 44 |
url 'http://projects.andriylesyuk.com/projects/scm-creator' |
44 | 45 |
version '0.5.0b' |
46 |
project_module :repository do |
|
47 |
permission :download_svn_revision, :download_svn_revision => :index |
|
48 |
end |
|
49 | ||
45 | 50 |
end |
lib/creator/#subversion_creator.rb# | ||
---|---|---|
1 |
eclass SubversionCreator < SCMCreator |
|
2 | ||
3 |
class << self |
|
4 | ||
5 |
def scm_id |
|
6 |
'svn' |
|
7 |
end |
|
8 | ||
9 |
def enabled? |
|
10 |
if options |
|
11 |
if options['path'] |
|
12 |
if !options['svnadmin'] || File.executable?(options['svnadmin']) |
|
13 |
return true |
|
14 |
else |
|
15 |
Rails.logger.warn "'#{options['svnadmin']}' cannot be found/executed - ignoring '#{scm_id}" |
|
16 |
end |
|
17 |
else |
|
18 |
Rails.logger.warn "missing path for '#{scm_id}'" |
|
19 |
end |
|
20 |
end |
|
21 | ||
22 |
false |
|
23 |
end |
|
24 | ||
25 |
def access_url(path, repository = nil) |
|
26 |
if options['append'] |
|
27 |
access_root_url(path, repository) + '/' + options['append'] |
|
28 |
else |
|
29 |
access_root_url(path, repository) |
|
30 |
end |
|
31 |
end |
|
32 | ||
33 |
def access_root_url(path, repository = nil) |
|
34 |
'file://' + (Redmine::Platform.mswin? ? '/' + path.gsub(%r{\\}, "/") : path) |
|
35 |
end |
|
36 | ||
37 |
def external_url(repository, regexp = %r{^(?:file|https?|svn(?:\+[a-z]+)?)://}) |
|
38 |
super |
|
39 |
end |
|
40 | ||
41 |
def repository_name(path) |
|
42 |
base = Redmine::Platform.mswin? ? '/' + options['path'].gsub(%r{\\}, "/") : options['path'] |
|
43 |
matches = Regexp.new("^file://#{Regexp.escape(base)}/([^/]+)/?$").match(path) |
|
44 |
matches ? matches[1] : nil |
|
45 |
end |
|
46 | ||
47 |
def repository_format |
|
48 |
path = Redmine::Platform.mswin? ? '/' + options['path'].gsub(%r{\\}, "/") : options['path'] |
|
49 |
"file://#{path}/<#{l(:label_repository_format)}>/" |
|
50 |
end |
|
51 | ||
52 |
def create_repository(path, repository = nil) |
|
53 |
args = [ svnadmin_command, 'create', path ] |
|
54 |
append_options(args) |
|
55 |
system(*args) |
|
56 |
end |
|
57 | ||
58 |
private |
|
59 | ||
60 |
def svnadmin_command |
|
61 |
options['svnadmin'] || 'svnadmin' |
|
62 |
end |
|
63 | ||
64 |
end |
|
65 | ||
66 |
end |