Feature #779 » 002_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 | |
13 |
- |
test/unit/changeset_test.rb | ||
---|---|---|
32 | 32 |
Setting.commit_ref_keywords = '*' |
33 | 33 |
Setting.commit_fix_keywords = 'fixes , closes' |
34 | 34 |
|
35 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
35 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
36 | 36 |
:committed_on => Time.now, |
37 | 37 |
:comments => 'New commit (#2). Fixes #1') |
38 | 38 |
c.scan_comment_for_issue_ids |
... | ... | |
48 | 48 |
Setting.commit_ref_keywords = 'refs' |
49 | 49 |
Setting.commit_fix_keywords = '' |
50 | 50 |
|
51 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
51 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
52 | 52 |
:committed_on => Time.now, |
53 | 53 |
:comments => 'Ignores #2. Refs #1') |
54 | 54 |
c.scan_comment_for_issue_ids |
... | ... | |
60 | 60 |
Setting.commit_ref_keywords = '*' |
61 | 61 |
Setting.commit_fix_keywords = '' |
62 | 62 |
|
63 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
63 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
64 | 64 |
:committed_on => Time.now, |
65 | 65 |
:comments => 'Ignores #2. Refs #1') |
66 | 66 |
c.scan_comment_for_issue_ids |
... | ... | |
72 | 72 |
Setting.commit_ref_keywords = '*' |
73 | 73 |
Setting.commit_logtime_enabled = '1' |
74 | 74 | |
75 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
75 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
76 | 76 |
:committed_on => 24.hours.ago, |
77 | 77 |
:comments => 'Worked on this issue #1 @2h', |
78 | 78 |
:revision => '520', |
... | ... | |
98 | 98 |
Setting.commit_fix_keywords = 'fixes , closes' |
99 | 99 |
Setting.commit_logtime_enabled = '1' |
100 | 100 |
|
101 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
101 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
102 | 102 |
:committed_on => Time.now, |
103 | 103 |
:comments => 'This is a comment. Fixes #1 @2.5, #2 @1', |
104 | 104 |
:user => User.find(2)) |
... | ... | |
117 | 117 |
def test_ref_keywords_any_line_start |
118 | 118 |
Setting.commit_ref_keywords = '*' |
119 | 119 | |
120 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
120 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
121 | 121 |
:committed_on => Time.now, |
122 | 122 |
:comments => '#1 is the reason of this commit') |
123 | 123 |
c.scan_comment_for_issue_ids |
... | ... | |
128 | 128 |
def test_ref_keywords_allow_brackets_around_a_issue_number |
129 | 129 |
Setting.commit_ref_keywords = '*' |
130 | 130 | |
131 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
131 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
132 | 132 |
:committed_on => Time.now, |
133 | 133 |
:comments => '[#1] Worked on this issue') |
134 | 134 |
c.scan_comment_for_issue_ids |
... | ... | |
139 | 139 |
def test_ref_keywords_allow_brackets_around_multiple_issue_numbers |
140 | 140 |
Setting.commit_ref_keywords = '*' |
141 | 141 | |
142 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
142 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
143 | 143 |
:committed_on => Time.now, |
144 | 144 |
:comments => '[#1 #2, #3] Worked on these') |
145 | 145 |
c.scan_comment_for_issue_ids |
... | ... | |
148 | 148 |
end |
149 | 149 |
|
150 | 150 |
def test_commit_referencing_a_subproject_issue |
151 |
c = Changeset.new(:repository => Project.find(1).repository, |
|
151 |
c = Changeset.new(:repository => Project.find(1).repository.first,
|
|
152 | 152 |
:committed_on => Time.now, |
153 | 153 |
:comments => 'refs #5, a subproject issue') |
154 | 154 |
c.scan_comment_for_issue_ids |
155 |
- |
app/controllers/sys_controller.rb | ||
---|---|---|
24 | 24 |
end |
25 | 25 |
|
26 | 26 |
def create_project_repository |
27 |
|
|
27 | 28 |
project = Project.find(params[:id]) |
28 |
if project.repository |
|
29 |
render :nothing => true, :status => 409 |
|
29 | ||
30 |
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}." |
|
31 |
project.repository.push(Repository.factory(params[:vendor], params[:repository])) |
|
32 |
if project.repository.last.save |
|
33 |
render :xml => project.repository.last, :status => 201 |
|
30 | 34 |
else |
31 |
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}." |
|
32 |
project.repository = Repository.factory(params[:vendor], params[:repository]) |
|
33 |
if project.repository && project.repository.save |
|
34 |
render :xml => project.repository, :status => 201 |
|
35 |
else |
|
36 |
render :nothing => true, :status => 422 |
|
37 |
end |
|
35 |
render :nothing => true, :status => 422 |
|
38 | 36 |
end |
39 | 37 |
end |
40 | 38 |
|
41 |
- |
test/functional/repositories_controller_test.rb | ||
---|---|---|
72 | 72 |
def test_committers |
73 | 73 |
@request.session[:user_id] = 2 |
74 | 74 |
# add a commit with an unknown user |
75 |
Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.') |
|
75 |
Changeset.create!(:repository => Project.find(1).repository.first, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
|
|
76 | 76 |
|
77 | 77 |
get :committers, :id => 1 |
78 | 78 |
assert_response :success |
... | ... | |
94 | 94 |
def test_map_committers |
95 | 95 |
@request.session[:user_id] = 2 |
96 | 96 |
# add a commit with an unknown user |
97 |
c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.') |
|
97 |
c = Changeset.create!(:repository => Project.find(1).repository.first, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
|
|
98 | 98 |
|
99 | 99 |
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do |
100 | 100 |
post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} |
test/functional/repositories_cvs_controller_test.rb | ||
---|---|---|
38 | 38 |
User.current = nil |
39 | 39 | |
40 | 40 |
@project = Project.find(1) |
41 |
@project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
|
|
42 |
:url => MODULE_NAME) |
|
41 |
@project.repository.push(Repository::Cvs.create(:root_url => REPOSITORY_PATH,
|
|
42 |
:url => MODULE_NAME))
|
|
43 | 43 |
end |
44 | 44 |
|
45 | 45 |
if File.directory?(REPOSITORY_PATH) |
test/functional/sys_controller_test.rb | ||
---|---|---|
42 | 42 |
end |
43 | 43 | |
44 | 44 |
def test_create_project_repository |
45 |
assert_nil Project.find(4).repository |
|
45 |
assert_nil Project.find(4).repository.first
|
|
46 | 46 |
|
47 | 47 |
post :create_project_repository, :id => 4, |
48 | 48 |
:vendor => 'Subversion', |
49 |
:repository => { :url => 'file:///create/project/repository/subproject2'} |
|
49 |
:repository => { |
|
50 |
:url => 'file:///create/project/repository/subproject2', |
|
51 |
:name => 'Test Subversion Repository' } |
|
52 |
|
|
53 |
|
|
50 | 54 |
assert_response :created |
51 | 55 |
|
52 |
r = Project.find(4).repository |
|
56 |
r = Project.find(4).repository.first
|
|
53 | 57 |
assert r.is_a?(Repository::Subversion) |
54 | 58 |
assert_equal 'file:///create/project/repository/subproject2', r.url |
55 | 59 |
end |
test/unit/project_test.rb | ||
---|---|---|
48 | 48 |
should_have_many :boards |
49 | 49 |
should_have_many :changesets, :through => :repository |
50 | 50 | |
51 |
should_have_one :repository
|
|
51 |
should_have_many :repository
|
|
52 | 52 |
should_have_one :wiki |
53 | 53 | |
54 | 54 |
should_have_and_belong_to_many :trackers |
test/unit/repository_test.rb | ||
---|---|---|
35 | 35 |
:enumerations |
36 | 36 |
|
37 | 37 |
def setup |
38 |
@repository = Project.find(1).repository |
|
38 |
@repository = Project.find(1).repository.first
|
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
def test_create |
42 |
- |
app/views/repositories/revision.rhtml | ||
---|---|---|
19 | 19 |
<% end %> |
20 | 20 |
</div> |
21 | 21 | |
22 |
<h1><%= link_to(@changeset.repository.display_name, :controller => 'repositories', :rid => @changeset.rid, :action => 'show') %></h1><br/> |
|
22 | 23 |
<h2><%= l(:label_revision) %> <%= format_revision(@changeset) %></h2> |
23 | 24 | |
24 | 25 |
<p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> |