Feature #779 » 0001-.patch
app/controllers/repositories_controller.rb | ||
---|---|---|
36 | 36 |
|
37 | 37 |
def edit |
38 | 38 |
@repository = @project.repository |
39 |
if !@repository |
|
40 |
@repository = Repository.factory(params[:repository_scm]) |
|
41 |
@repository.project = @project if @repository |
|
39 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
40 |
if !@repository[rid] |
|
41 |
@repository[rid] = Repository.factory(params[:repository_scm]) |
|
42 |
@repository[rid].project = @project if @repository[rid] |
|
42 | 43 |
end |
43 |
if request.post? && @repository |
|
44 |
@repository.attributes = params[:repository]
|
|
45 |
@repository.save
|
|
44 |
if request.post? && @repository[rid]
|
|
45 |
@repository[rid].attributes = params[:repository]
|
|
46 |
@repository[rid].save
|
|
46 | 47 |
end |
47 | 48 |
render(:update) do |page| |
48 | 49 |
page.replace_html "tab-content-repository", :partial => 'projects/settings/repository' |
... | ... | |
139 | 140 |
end |
140 | 141 |
|
141 | 142 |
def revision |
142 |
@changeset = @repository.find_changeset_by_name(@rev) |
|
143 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
144 |
@changeset = @project.repository[rid].find_changeset_by_name(@rev) |
|
143 | 145 |
raise ChangesetNotFound unless @changeset |
144 | 146 | |
145 | 147 |
respond_to do |format| |
... | ... | |
199 | 201 |
private |
200 | 202 |
def find_repository |
201 | 203 |
@project = Project.find(params[:id]) |
202 |
@repository = @project.repository |
|
204 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
205 |
@repository = @project.repository[rid] |
|
203 | 206 |
(render_404; return false) unless @repository |
204 | 207 |
@path = params[:path].join('/') unless params[:path].nil? |
205 | 208 |
@path ||= '' |
app/helpers/application_helper.rb | ||
---|---|---|
105 | 105 |
def link_to_revision(revision, project, options={}) |
106 | 106 |
text = options.delete(:text) || format_revision(revision) |
107 | 107 | |
108 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision)) |
|
108 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, revision))
|
|
109 | 109 |
end |
110 | 110 | |
111 | 111 |
# Generates a link to a project if active |
app/helpers/repositories_helper.rb | ||
---|---|---|
87 | 87 |
:action => 'show', |
88 | 88 |
:id => @project, |
89 | 89 |
:path => path_param, |
90 |
:rev => @changeset.revision) |
|
90 |
:rev => @changeset.revision, |
|
91 |
:rid => params[:rid]) |
|
91 | 92 |
output << "<li class='#{style}'>#{text}</li>" |
92 | 93 |
output << render_changes_tree(s) |
93 | 94 |
elsif c = tree[file][:c] |
... | ... | |
97 | 98 |
:action => 'entry', |
98 | 99 |
:id => @project, |
99 | 100 |
:path => path_param, |
100 |
:rev => @changeset.revision) unless c.action == 'D' |
|
101 |
:rev => @changeset.revision, |
|
102 |
:rid => params[:rid]) unless c.action == 'D' |
|
101 | 103 |
text << " - #{c.revision}" unless c.revision.blank? |
102 | 104 |
text << ' (' + link_to('diff', :controller => 'repositories', |
103 | 105 |
:action => 'diff', |
104 | 106 |
:id => @project, |
105 | 107 |
:path => path_param, |
106 |
:rev => @changeset.revision) + ') ' if c.action == 'M' |
|
108 |
:rev => @changeset.revision, |
|
109 |
:rid => params[:rid]) + ') ' if c.action == 'M' |
|
107 | 110 |
text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank? |
108 | 111 |
output << "<li class='#{style}'>#{text}</li>" |
109 | 112 |
end |
... | ... | |
130 | 133 |
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' |
131 | 134 |
end |
132 | 135 |
|
133 |
def scm_select_tag(repository)
|
|
136 |
def scm_select_tag(repository, rid)
|
|
134 | 137 |
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']] |
135 | 138 |
Redmine::Scm::Base.all.each do |scm| |
136 | 139 |
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm) |
... | ... | |
139 | 142 |
select_tag('repository_scm', |
140 | 143 |
options_for_select(scm_options, repository.class.name.demodulize), |
141 | 144 |
:disabled => (repository && !repository.new_record?), |
142 |
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
|
|
145 |
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid }, :method => :get, :with => "Form.serialize(this.form)")
|
|
143 | 146 |
) |
144 | 147 |
end |
145 | 148 |
|
app/models/changeset.rb | ||
---|---|---|
161 | 161 |
:from_revision => change[:from_revision]) |
162 | 162 |
end |
163 | 163 |
|
164 |
def rid |
|
165 |
project.repository.each_with_index do |r, i| |
|
166 |
return i if r.id == repository.id |
|
167 |
end |
|
168 |
-1 |
|
169 |
end |
|
170 |
|
|
164 | 171 |
private |
165 | 172 | |
166 | 173 |
# Finds issues that can be referenced by the commit message |
app/models/project.rb | ||
---|---|---|
41 | 41 |
has_many :news, :dependent => :delete_all, :include => :author |
42 | 42 |
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name" |
43 | 43 |
has_many :boards, :dependent => :destroy, :order => "position ASC" |
44 |
has_one :repository, :dependent => :destroy
|
|
44 |
has_many :repository, :dependent => :destroy
|
|
45 | 45 |
has_many :changesets, :through => :repository |
46 | 46 |
has_one :wiki, :dependent => :destroy |
47 | 47 |
# Custom field for the project issues |
app/views/issues/_changesets.rhtml | ||
---|---|---|
1 | 1 |
<% changesets.each do |changeset| %> |
2 | 2 |
<div class="changeset <%= cycle('odd', 'even') %>"> |
3 | 3 |
<p><%= link_to("#{l(:label_revision)} #{changeset.revision}", |
4 |
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %><br /> |
|
4 |
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision, :rid => changeset.rid) %><br />
|
|
5 | 5 |
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> |
6 | 6 |
<div class="changeset-changes"> |
7 | 7 |
<%= textilizable(changeset, :comments) %> |
app/views/projects/settings/_repository.rhtml | ||
---|---|---|
1 |
<% remote_form_for :repository, @repository, |
|
2 |
:url => { :controller => 'repositories', :action => 'edit', :id => @project }, |
|
1 |
<% @repository.each_with_index do |r, rid| %> |
|
2 |
<% remote_form_for :repository, r, |
|
3 |
:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid }, |
|
3 | 4 |
:builder => TabularFormBuilder, |
4 | 5 |
:lang => current_language do |f| %> |
5 | 6 | |
6 |
<%= error_messages_for 'repository' %>
|
|
7 |
<%= error_messages_for 'r' %>
|
|
7 | 8 | |
8 | 9 |
<div class="box tabular"> |
9 |
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %></p>
|
|
10 |
<%= repository_field_tags(f, @repository) if @repository %>
|
|
10 |
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(r, rid) %></p>
|
|
11 |
<%= repository_field_tags(f, r) if r %>
|
|
11 | 12 |
</div> |
12 | 13 | |
13 | 14 |
<div class="contextual"> |
14 |
<% if @repository && !@repository.new_record? %>
|
|
15 |
<%= link_to(l(:label_user_plural), {:controller => 'repositories', :action => 'committers', :id => @project}, :class => 'icon icon-user') %>
|
|
16 |
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project},
|
|
15 |
<% if @repository[0] && !r.new_record? %>
|
|
16 |
<%= link_to(l(:label_user_plural), {:controller => 'repositories', :action => 'committers', :id => @project, :rid => rid}, :class => 'icon icon-user') %>
|
|
17 |
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project, :rid => rid},
|
|
17 | 18 |
:confirm => l(:text_are_you_sure), |
18 | 19 |
:method => :post, |
19 | 20 |
:class => 'icon icon-del') %> |
20 | 21 |
<% end %> |
21 | 22 |
</div> |
22 | 23 | |
23 |
<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %> |
|
24 |
<%= submit_tag((r.nil? || r.new_record?) ? l(:button_create) : l(:button_save), :disabled => r.nil?) %> |
|
25 |
<% end %> |
|
26 |
<% end %> |
|
27 |
|
|
28 |
<% rid = @repository.size |
|
29 |
remote_form_for :repository, @repository[rid], |
|
30 |
:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid }, |
|
31 |
:builder => TabularFormBuilder, |
|
32 |
:lang => current_language do |f| %> |
|
33 |
<div class="box tabular"> |
|
34 |
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository[rid], rid) %></p> |
|
35 |
<%= repository_field_tags(f, @repository[rid]) if @repository[rid] %> |
|
36 |
</div> |
|
37 |
<%= submit_tag((@repository[rid].nil? || @repository[rid].new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository[rid].nil?) %> |
|
24 | 38 |
<% end %> |
app/views/repositories/_dir_list_content.rhtml | ||
---|---|---|
4 | 4 |
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> |
5 | 5 |
<td style="padding-left: <%=18 * depth%>px;" class="filename"> |
6 | 6 |
<% if entry.is_dir? %> |
7 |
<span class="expander" onclick="<%= remote_function :url => {:action => 'show', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id},
|
|
7 |
<span class="expander" onclick="<%= remote_function :url => {:action => 'show', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id, :rid => params[:rid]},
|
|
8 | 8 |
:method => :get, |
9 | 9 |
:update => { :success => tr_id }, |
10 | 10 |
:position => :after, |
... | ... | |
12 | 12 |
:condition => "scmEntryClick('#{tr_id}')"%>"> </span> |
13 | 13 |
<% end %> |
14 | 14 |
<%= link_to h(entry.name), |
15 |
{:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
|
|
15 |
{:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev, :rid => params[:rid]},
|
|
16 | 16 |
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(entry.name)}")%> |
17 | 17 |
</td> |
18 | 18 |
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td> |
19 |
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
|
|
19 |
<% changeset = @project.repository[params[:rid].to_i].changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
|
|
20 | 20 |
<td class="revision"><%= link_to_revision(changeset.revision, @project) if changeset %></td> |
21 | 21 |
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> |
22 | 22 |
<td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td> |
app/views/repositories/_navigation.rhtml | ||
---|---|---|
16 | 16 |
<%= select_tag :tag, options_for_select([''] + @repository.tags,@rev), :id => 'tag' %> |
17 | 17 |
<% end -%> |
18 | 18 | |
19 |
<%= hidden_field_tag :rid, params[:rid] %> |
|
20 | ||
19 | 21 |
| <%= l(:label_revision) %>: |
20 | 22 |
<%= text_field_tag 'rev', @rev, :size => 8 %> |
21 | 23 |
<% end -%> |
app/views/repositories/show.rhtml | ||
---|---|---|
4 | 4 |
<%= render :partial => 'navigation' %> |
5 | 5 |
</div> |
6 | 6 | |
7 |
<ul> |
|
8 |
<% @project.repository.each_with_index do |r, i| %> |
|
9 |
<li><%= link_to r.url, :rid => i %></li> |
|
10 |
<% end %> |
|
11 |
</ul> |
|
12 |
|
|
7 | 13 |
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2> |
8 | 14 | |
9 | 15 |
<% if !@entries.nil? && authorize_for('repositories', 'browse') %> |
lib/redmine.rb | ||
---|---|---|
201 | 201 |
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
202 | 202 |
menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id |
203 | 203 |
menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
204 |
:if => Proc.new { |p| p.repository && !p.repository.new_record? }
|
|
204 |
:if => Proc.new { |p| p.repository && p.repository[0] && !p.repository[0].new_record? }
|
|
205 | 205 |
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
206 | 206 |
end |
207 | 207 |