Feature #779 » multi_repo.patch
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
|
||
|
def edit
|
||
|
@repository = @project.repository
|
||
|
if !@repository
|
||
|
@repository = Repository.factory(params[:repository_scm])
|
||
|
@repository.project = @project if @repository
|
||
|
rid = params[:rid] ? params[:rid].to_i : 0
|
||
|
|
||
|
if !@repository[rid]
|
||
|
@repository[rid] = Repository.factory(params[:repository_scm])
|
||
|
@repository[rid].project = @project if @repository[rid]
|
||
|
end
|
||
|
if request.post? && @repository
|
||
|
@repository.attributes = params[:repository]
|
||
|
@repository.save
|
||
|
if request.post? && @repository[rid]
|
||
|
@repository[rid].attributes = params[:repository]
|
||
|
@repository[rid].save
|
||
|
end
|
||
|
render(:update) do |page|
|
||
|
page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'
|
||
|
if @repository && !@project.repository
|
||
|
if @repository[rid] && !@project.repository
|
||
|
@project.reload #needed to reload association
|
||
|
page.replace_html "main-menu", render_main_menu(@project)
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def revision
|
||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||
|
rid = params[:rid] ? params[:rid].to_i : 0
|
||
|
@changeset = @repository[rid].find_changeset_by_name(@rev)
|
||
|
raise ChangesetNotFound unless @changeset
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
def find_repository
|
||
|
@project = Project.find(params[:id])
|
||
|
@repository = @project.repository
|
||
|
rid = params[:rid] ? params[:rid].to_i : 0
|
||
|
@repository = @project.repository[rid]
|
||
|
(render_404; return false) unless @repository
|
||
|
@path = params[:path].join('/') unless params[:path].nil?
|
||
|
@path ||= ''
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
text = options.delete(:text) || format_revision(revision)
|
||
|
rev = revision.respond_to?(:identifier) ? revision.identifier : revision
|
||
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
||
|
:title => l(:label_revision_id, format_revision(revision)))
|
||
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, revision))
|
||
|
# link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
||
|
# :title => l(:label_revision_id, format_revision(revision)))
|
||
|
end
|
||
|
# Generates a link to a project if active
|
||
| app/helpers/repositories_helper.rb | ||
|---|---|---|
|
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
|
||
|
end
|
||
|
|
||
|
def scm_select_tag(repository)
|
||
|
def scm_select_tag(repository, rid)
|
||
|
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
|
||
|
Redmine::Scm::Base.all.each do |scm|
|
||
|
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
|
||
| ... | ... | |
|
select_tag('repository_scm',
|
||
|
options_for_select(scm_options, repository.class.name.demodulize),
|
||
|
:disabled => (repository && !repository.new_record?),
|
||
|
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
|
||
|
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid }, :method => :get, :with => "Form.serialize(this.form)")
|
||
|
)
|
||
|
end
|
||
|
|
||
| app/models/changeset.rb | ||
|---|---|---|
|
def next
|
||
|
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
|
||
|
end
|
||
|
def rid
|
||
|
project.repository.each_with_index do |r, i|
|
||
|
return i if r.id == repository.id
|
||
|
end
|
||
|
-1
|
||
|
end
|
||
|
|
||
|
# Strips and reencodes a commit log before insertion into the database
|
||
|
def self.normalize_comments(str)
|
||
| app/models/project.rb | ||
|---|---|---|
|
has_many :news, :dependent => :delete_all, :include => :author
|
||
|
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
||
|
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||
|
has_one :repository, :dependent => :destroy
|
||
|
has_many :repository, :dependent => :destroy
|
||
|
has_many :changesets, :through => :repository
|
||
|
has_one :wiki, :dependent => :destroy
|
||
|
# Custom field for the project issues
|
||
| app/views/projects/settings/_repository.rhtml | ||
|---|---|---|
|
<% remote_form_for :repository, @repository,
|
||
|
:url => { :controller => 'repositories', :action => 'edit', :id => @project },
|
||
|
<% @repository.each_with_index do |r, rid| %>
|
||
|
<% remote_form_for :repository, r,
|
||
|
:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid },
|
||
|
:builder => TabularFormBuilder,
|
||
|
:lang => current_language do |f| %>
|
||
|
<%= error_messages_for 'repository' %>
|
||
|
<%= error_messages_for 'r' %>
|
||
|
<div class="box tabular">
|
||
|
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %></p>
|
||
|
<%= repository_field_tags(f, @repository) if @repository %>
|
||
|
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(r, rid) %></p>
|
||
|
<%= repository_field_tags(f, r) if r %>
|
||
|
</div>
|
||
|
<div class="contextual">
|
||
|
<% if @repository && !@repository.new_record? %>
|
||
|
<%= link_to(l(:label_user_plural), {:controller => 'repositories', :action => 'committers', :id => @project}, :class => 'icon icon-user') %>
|
||
|
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project},
|
||
|
<% if @repository[0] && !r.new_record? %>
|
||
|
<%= link_to(l(:label_user_plural), {:controller => 'repositories', :action => 'committers', :id => @project, :rid => rid}, :class => 'icon icon-user') %>
|
||
|
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project, :rid => rid },
|
||
|
:confirm => l(:text_are_you_sure),
|
||
|
:method => :post,
|
||
|
:class => 'icon icon-del') %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %>
|
||
|
<%= submit_tag((r.nil? || r.new_record?) ? l(:button_create) : l(:button_save), :disabled => r.nil?) %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<% rid = @repository.size
|
||
|
remote_form_for :repository, @repository[rid],
|
||
|
:url => { :controller => 'repositories', :action => 'edit', :id => @project, :rid => rid },
|
||
|
:builder => TabularFormBuilder,
|
||
|
:lang => current_language do |f| %>
|
||
|
<div class="box tabular">
|
||
|
<p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository[rid], rid) %></p>
|
||
|
<%= repository_field_tags(f, @repository[rid]) if @repository[rid] %>
|
||
|
</div>
|
||
|
<%= submit_tag((@repository[rid].nil? || @repository[rid].new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository[rid].nil?) %>
|
||
|
<% end %>
|
||
| app/views/repositories/_dir_list_content.rhtml | ||
|---|---|---|
|
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
|
||
|
<td style="padding-left: <%=18 * depth%>px;" class="filename">
|
||
|
<% if entry.is_dir? %>
|
||
|
<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},
|
||
|
<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]},
|
||
|
:method => :get,
|
||
|
:update => { :success => tr_id },
|
||
|
:position => :after,
|
||
| ... | ... | |
|
:condition => "scmEntryClick('#{tr_id}')"%>"> </span>
|
||
|
<% end %>
|
||
|
<%= link_to h(entry.name),
|
||
|
{:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
|
||
|
{:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev, :rid => params[:rid]},
|
||
|
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(entry.name)}")%>
|
||
|
</td>
|
||
|
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
|
||
|
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
|
||
|
<% changeset = @project.repository[params[:rid].to_i].changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
|
||
|
<td class="revision"><%= link_to_revision(changeset, @project) if changeset %></td>
|
||
|
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
|
||
|
<td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td>
|
||
| app/views/repositories/show.rhtml | ||
|---|---|---|
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<ul>
|
||
|
<% @project.repository.each_with_index do |r, i| %>
|
||
|
<li><%= link_to r.url, :rid => i %></li>
|
||
|
<% end %>
|
||
|
</ul>
|
||
|
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
|
||
|
<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
|
||
| lib/redmine.rb | ||
|---|---|---|
|
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
|
||
|
menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
|
||
|
menu.push :repository, { :controller => 'repositories', :action => 'show' },
|
||
|
:if => Proc.new { |p| p.repository && !p.repository.new_record? }
|
||
|
:if => Proc.new { |p| !p.repository.empty? && !p.repository[0].new_record? }
|
||
|
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
|
||
|
end
|
||
|
-
|
||
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
(render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty?
|
||
|
end
|
||
|
|
||
|
def revision
|
||
|
rid = params[:rid] ? params[:rid].to_i : 0
|
||
|
@changeset = @repository[rid].find_changeset_by_name(@rev)
|
||
|
def revision
|
||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||
|
raise ChangesetNotFound unless @changeset
|
||
|
respond_to do |format|
|
||
| app/controllers/sys_controller.rb | ||
|---|---|---|
|
projects = Project.active.has_module(:repository).find(:all, :include => :repository)
|
||
|
end
|
||
|
projects.each do |project|
|
||
|
if project.repository
|
||
|
project.repository.fetch_changesets
|
||
|
if project.repository.length > 0
|
||
|
project.repository.each do |repo|
|
||
|
repo.fetch_changesets
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
render :nothing => true, :status => 200
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
def link_to_revision(revision, project, options={})
|
||
|
text = options.delete(:text) || format_revision(revision)
|
||
|
rev = revision.respond_to?(:identifier) ? revision.identifier : revision
|
||
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, revision))
|
||
|
# link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
||
|
# :title => l(:label_revision_id, format_revision(revision)))
|
||
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision, :rid => params[:rid]}, :title => l(:label_revision_id, format_revision(revision)))
|
||
|
end
|
||
|
# Generates a link to a project if active
|
||
| app/helpers/repositories_helper.rb | ||
|---|---|---|
|
|
||
|
def repository_field_tags(form, repository)
|
||
|
method = repository.class.name.demodulize.underscore + "_field_tags"
|
||
|
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
|
||
|
namefield = repositoryname_field_tag(form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
|
||
|
html = send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
|
||
|
return namefield + html
|
||
|
end
|
||
|
|
||
|
def scm_select_tag(repository, rid)
|
||
| ... | ... | |
|
def filesystem_field_tags(form, repository)
|
||
|
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
||
|
end
|
||
|
|
||
|
def repositoryname_field_tag(form, repository)
|
||
|
content_tag('p', form.text_field(:name, :label => 'Name', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
||
|
end
|
||
|
|
||
|
def link_to_repository(repository, rid)
|
||
|
link_to !repository.name.empty? ? repository.name : repository.url, :rid => rid
|
||
|
end
|
||
|
end
|
||
| app/views/issues/_changesets.rhtml | ||
|---|---|---|
|
<% changesets.each do |changeset| %>
|
||
|
<div class="changeset <%= cycle('odd', 'even') %>">
|
||
|
<p><%= link_to("#{l(:label_revision)} #{changeset.revision}",
|
||
|
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %><br />
|
||
|
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision, :rid => changeset.rid) %><br />
|
||
|
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p>
|
||
|
<div class="changeset-changes">
|
||
|
<%= textilizable(changeset, :comments) %>
|
||
| app/views/repositories/_breadcrumbs.rhtml | ||
|---|---|---|
|
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev %>
|
||
|
<%
|
||
|
<% if params[:rid] %>
|
||
|
(<%= @project.repository[params[:rid].to_i].url %>)
|
||
|
<% end %>
|
||
|
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev , :rid => params[:rid]%><%
|
||
|
dirs = path.split('/')
|
||
|
if 'file' == kind
|
||
|
filename = dirs.pop
|
||
| ... | ... | |
|
link_path << '/' unless link_path.empty?
|
||
|
link_path << "#{dir}"
|
||
|
%>
|
||
|
/ <%= link_to h(dir), :action => 'show', :id => @project, :path => to_path_param(link_path), :rev => @rev %>
|
||
|
/ <%= link_to h(dir), :action => 'show', :id => @project, :path => to_path_param(link_path), :rev => @rev, :rid => params[:rid] %>
|
||
|
<% end %>
|
||
|
<% if filename %>
|
||
|
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %>
|
||
|
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev, :rid => params[:rid] %>
|
||
|
<% end %>
|
||
|
<%= "@ #{h revision}" if revision %>
|
||
| app/views/repositories/_navigation.rhtml | ||
|---|---|---|
|
<%= select_tag :tag, options_for_select([''] + @repository.tags,@rev), :id => 'tag' %>
|
||
|
<% end -%>
|
||
|
<%= hidden_field_tag :rid, params[:rid] %>
|
||
|
|
||
|
| <%= l(:label_revision) %>:
|
||
|
<%= text_field_tag 'rev', @rev, :size => 8 %>
|
||
|
<% end -%>
|
||
| app/views/repositories/show.rhtml | ||
|---|---|---|
|
<ul>
|
||
|
<% @project.repository.each_with_index do |r, i| %>
|
||
|
<li><%= link_to r.url, :rid => i %></li>
|
||
|
<li><%= link_to_repository(r,i) %></li>
|
||
|
<% end %>
|
||
|
</ul>
|
||
| db/migrate/109_add_name_to_repository.rb | ||
|---|---|---|
|
class AddNameToRepository < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
add_column :repositories, :name, :string, :null => false, :default => ""
|
||
|
end
|
||
|
def self.down
|
||
|
remove_column :repositories, :name
|
||
|
end
|
||
|
end
|
||
|
-
|
||
| app/helpers/repositories_helper.rb | ||
|---|---|---|
|
def repositoryname_field_tag(form, repository)
|
||
|
content_tag('p', form.text_field(:name, :label => 'Name', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
||
|
end
|
||
|
|
||
|
def link_to_repository(repository, rid)
|
||
|
link_to !repository.name.empty? ? repository.name : repository.url, :rid => rid
|
||
|
end
|
||
|
end
|
||
| app/models/repository.rb | ||
|---|---|---|
|
write_attribute(:url, arg ? arg.to_s.strip : nil)
|
||
|
end
|
||
|
|
||
|
def display_name
|
||
|
self.name.empty? ? self.url : self.name
|
||
|
end
|
||
|
|
||
|
# Removes leading and trailing whitespace
|
||
|
def root_url=(arg)
|
||
|
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
||
| app/views/repositories/_breadcrumbs.rhtml | ||
|---|---|---|
|
<% if params[:rid] %>
|
||
|
(<%= @project.repository[params[:rid].to_i].url %>)
|
||
|
(<%= @project.repository[params[:rid].to_i].display_name %>)
|
||
|
<% end %>
|
||
|
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev , :rid => params[:rid]%><%
|
||
|
dirs = path.split('/')
|
||
| app/views/repositories/show.rhtml | ||
|---|---|---|
|
<ul>
|
||
|
<% @project.repository.each_with_index do |r, i| %>
|
||
|
<li><%= link_to_repository(r,i) %></li>
|
||
|
<li><%= link_to r.display_name, :rid => i %></li>
|
||
|
<% end %>
|
||
|
</ul>
|
||