Feature #779 » multi_repo.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 |
|
|
41 |
if !@repository[rid] |
|
42 |
@repository[rid] = Repository.factory(params[:repository_scm]) |
|
43 |
@repository[rid].project = @project if @repository[rid] |
|
42 | 44 |
end |
43 |
if request.post? && @repository |
|
44 |
@repository.attributes = params[:repository] |
|
45 |
@repository.save |
|
45 |
if request.post? && @repository[rid]
|
|
46 |
@repository[rid].attributes = params[:repository]
|
|
47 |
@repository[rid].save
|
|
46 | 48 |
end |
47 | 49 |
render(:update) do |page| |
48 | 50 |
page.replace_html "tab-content-repository", :partial => 'projects/settings/repository' |
49 |
if @repository && !@project.repository |
|
51 |
if @repository[rid] && !@project.repository
|
|
50 | 52 |
@project.reload #needed to reload association |
51 | 53 |
page.replace_html "main-menu", render_main_menu(@project) |
52 | 54 |
end |
... | ... | |
139 | 141 |
end |
140 | 142 |
|
141 | 143 |
def revision |
142 |
@changeset = @repository.find_changeset_by_name(@rev) |
|
144 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
145 |
@changeset = @repository[rid].find_changeset_by_name(@rev) |
|
143 | 146 |
raise ChangesetNotFound unless @changeset |
144 | 147 | |
145 | 148 |
respond_to do |format| |
... | ... | |
205 | 208 | |
206 | 209 |
def find_repository |
207 | 210 |
@project = Project.find(params[:id]) |
208 |
@repository = @project.repository |
|
211 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
212 |
@repository = @project.repository[rid] |
|
209 | 213 |
(render_404; return false) unless @repository |
210 | 214 |
@path = params[:path].join('/') unless params[:path].nil? |
211 | 215 |
@path ||= '' |
app/helpers/application_helper.rb | ||
---|---|---|
106 | 106 |
text = options.delete(:text) || format_revision(revision) |
107 | 107 |
rev = revision.respond_to?(:identifier) ? revision.identifier : revision |
108 | 108 | |
109 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, |
|
110 |
:title => l(:label_revision_id, format_revision(revision))) |
|
109 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, revision)) |
|
110 |
# link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, |
|
111 |
# :title => l(:label_revision_id, format_revision(revision))) |
|
111 | 112 |
end |
112 | 113 | |
113 | 114 |
# Generates a link to a project if active |
app/helpers/repositories_helper.rb | ||
---|---|---|
140 | 140 |
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' |
141 | 141 |
end |
142 | 142 |
|
143 |
def scm_select_tag(repository) |
|
143 |
def scm_select_tag(repository, rid)
|
|
144 | 144 |
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']] |
145 | 145 |
Redmine::Scm::Base.all.each do |scm| |
146 | 146 |
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm) |
... | ... | |
149 | 149 |
select_tag('repository_scm', |
150 | 150 |
options_for_select(scm_options, repository.class.name.demodulize), |
151 | 151 |
:disabled => (repository && !repository.new_record?), |
152 |
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") |
|
152 |
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid }, :method => :get, :with => "Form.serialize(this.form)")
|
|
153 | 153 |
) |
154 | 154 |
end |
155 | 155 |
|
app/models/changeset.rb | ||
---|---|---|
160 | 160 |
def next |
161 | 161 |
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC') |
162 | 162 |
end |
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 |
|
163 | 170 |
|
164 | 171 |
# Strips and reencodes a commit log before insertion into the database |
165 | 172 |
def self.normalize_comments(str) |
app/models/project.rb | ||
---|---|---|
46 | 46 |
has_many :news, :dependent => :delete_all, :include => :author |
47 | 47 |
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name" |
48 | 48 |
has_many :boards, :dependent => :destroy, :order => "position ASC" |
49 |
has_one :repository, :dependent => :destroy
|
|
49 |
has_many :repository, :dependent => :destroy
|
|
50 | 50 |
has_many :changesets, :through => :repository |
51 | 51 |
has_one :wiki, :dependent => :destroy |
52 | 52 |
# Custom field for the project issues |
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?) %>
|
|
24 | 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?) %> |
|
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, @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/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.empty? && !p.repository[0].new_record? }
|
|
205 | 205 |
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
206 | 206 |
end |
207 | 207 | |
208 |
- |
app/controllers/repositories_controller.rb | ||
---|---|---|
140 | 140 |
(render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty? |
141 | 141 |
end |
142 | 142 |
|
143 |
def revision |
|
144 |
rid = params[:rid] ? params[:rid].to_i : 0 |
|
145 |
@changeset = @repository[rid].find_changeset_by_name(@rev) |
|
143 |
def revision |
|
144 |
@changeset = @repository.find_changeset_by_name(@rev) |
|
146 | 145 |
raise ChangesetNotFound unless @changeset |
147 | 146 | |
148 | 147 |
respond_to do |format| |
app/controllers/sys_controller.rb | ||
---|---|---|
46 | 46 |
projects = Project.active.has_module(:repository).find(:all, :include => :repository) |
47 | 47 |
end |
48 | 48 |
projects.each do |project| |
49 |
if project.repository |
|
50 |
project.repository.fetch_changesets |
|
49 |
if project.repository.length > 0 |
|
50 |
project.repository.each do |repo| |
|
51 |
repo.fetch_changesets |
|
52 |
end |
|
51 | 53 |
end |
52 | 54 |
end |
53 | 55 |
render :nothing => true, :status => 200 |
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 |
rev = revision.respond_to?(:identifier) ? revision.identifier : revision |
108 | ||
109 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, revision)) |
|
110 |
# link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, |
|
111 |
# :title => l(:label_revision_id, format_revision(revision))) |
|
108 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, format_revision(revision))) |
|
112 | 109 |
end |
113 | 110 | |
114 | 111 |
# Generates a link to a project if active |
app/helpers/repositories_helper.rb | ||
---|---|---|
137 | 137 |
|
138 | 138 |
def repository_field_tags(form, repository) |
139 | 139 |
method = repository.class.name.demodulize.underscore + "_field_tags" |
140 |
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' |
|
140 |
namefield = repositoryname_field_tag(form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' |
|
141 |
html = send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' |
|
142 |
return namefield + html |
|
141 | 143 |
end |
142 | 144 |
|
143 | 145 |
def scm_select_tag(repository, rid) |
... | ... | |
195 | 197 |
def filesystem_field_tags(form, repository) |
196 | 198 |
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
197 | 199 |
end |
200 |
|
|
201 |
def repositoryname_field_tag(form, repository) |
|
202 |
content_tag('p', form.text_field(:name, :label => 'Name', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
|
203 |
end |
|
204 |
|
|
205 |
def link_to_repository(repository, rid) |
|
206 |
link_to !repository.name.empty? ? repository.name : repository.url, :rid => rid |
|
207 |
end |
|
198 | 208 |
end |
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/repositories/_breadcrumbs.rhtml | ||
---|---|---|
1 |
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev %> |
|
2 |
<% |
|
1 |
<% if params[:rid] %> |
|
2 |
(<%= @project.repository[params[:rid].to_i].url %>) |
|
3 |
<% end %> |
|
4 |
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev , :rid => params[:rid]%><% |
|
3 | 5 |
dirs = path.split('/') |
4 | 6 |
if 'file' == kind |
5 | 7 |
filename = dirs.pop |
... | ... | |
10 | 12 |
link_path << '/' unless link_path.empty? |
11 | 13 |
link_path << "#{dir}" |
12 | 14 |
%> |
13 |
/ <%= link_to h(dir), :action => 'show', :id => @project, :path => to_path_param(link_path), :rev => @rev %> |
|
15 |
/ <%= link_to h(dir), :action => 'show', :id => @project, :path => to_path_param(link_path), :rev => @rev, :rid => params[:rid] %>
|
|
14 | 16 |
<% end %> |
15 | 17 |
<% if filename %> |
16 |
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %> |
|
18 |
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev, :rid => params[:rid] %>
|
|
17 | 19 |
<% end %> |
18 | 20 | |
19 | 21 |
<%= "@ #{h revision}" if revision %> |
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 | ||
---|---|---|
6 | 6 | |
7 | 7 |
<ul> |
8 | 8 |
<% @project.repository.each_with_index do |r, i| %> |
9 |
<li><%= link_to r.url, :rid => i %></li>
|
|
9 |
<li><%= link_to_repository(r,i) %></li>
|
|
10 | 10 |
<% end %> |
11 | 11 |
</ul> |
12 | 12 |
db/migrate/109_add_name_to_repository.rb | ||
---|---|---|
1 |
class AddNameToRepository < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
add_column :repositories, :name, :string, :null => false, :default => "" |
|
4 |
end |
|
5 | ||
6 |
def self.down |
|
7 |
remove_column :repositories, :name |
|
8 |
end |
|
9 |
end |
|
0 |
- |
app/helpers/repositories_helper.rb | ||
---|---|---|
201 | 201 |
def repositoryname_field_tag(form, repository) |
202 | 202 |
content_tag('p', form.text_field(:name, :label => 'Name', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
203 | 203 |
end |
204 |
|
|
205 |
def link_to_repository(repository, rid) |
|
206 |
link_to !repository.name.empty? ? repository.name : repository.url, :rid => rid |
|
207 |
end |
|
208 | 204 |
end |
app/models/repository.rb | ||
---|---|---|
32 | 32 |
write_attribute(:url, arg ? arg.to_s.strip : nil) |
33 | 33 |
end |
34 | 34 |
|
35 |
def display_name |
|
36 |
self.name.empty? ? self.url : self.name |
|
37 |
end |
|
38 |
|
|
35 | 39 |
# Removes leading and trailing whitespace |
36 | 40 |
def root_url=(arg) |
37 | 41 |
write_attribute(:root_url, arg ? arg.to_s.strip : nil) |
app/views/repositories/_breadcrumbs.rhtml | ||
---|---|---|
1 | 1 |
<% if params[:rid] %> |
2 |
(<%= @project.repository[params[:rid].to_i].url %>)
|
|
2 |
(<%= @project.repository[params[:rid].to_i].display_name %>)
|
|
3 | 3 |
<% end %> |
4 | 4 |
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev , :rid => params[:rid]%><% |
5 | 5 |
dirs = path.split('/') |
app/views/repositories/show.rhtml | ||
---|---|---|
6 | 6 | |
7 | 7 |
<ul> |
8 | 8 |
<% @project.repository.each_with_index do |r, i| %> |
9 |
<li><%= link_to_repository(r,i) %></li>
|
|
9 |
<li><%= link_to r.display_name, :rid => i %></li>
|
|
10 | 10 |
<% end %> |
11 | 11 |
</ul> |
12 | 12 |