Feature #5386 » 5386-branches-in-associated-revisions.diff
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
| 110 | 110 |
:title => l(:label_revision_id, format_revision(revision))) |
| 111 | 111 |
end |
| 112 | 112 | |
| 113 |
# Generates a link to a SCM repository |
|
| 114 |
def link_to_repository(rev, project, options={})
|
|
| 115 |
text = options.delete(:text) || rev |
|
| 116 |
link_to(text, {:controller => 'repositories', :action => 'show', :id => project, :rev => rev},
|
|
| 117 |
:title => rev) |
|
| 118 |
end |
|
| 119 | ||
| 113 | 120 |
# Generates a link to a message |
| 114 | 121 |
def link_to_message(message, options={}, html_options = nil)
|
| 115 | 122 |
link_to( |
| app/models/repository/git.rb (working copy) | ||
|---|---|---|
| 136 | 136 |
if db_rev.nil? |
| 137 | 137 |
save_revision(rev) |
| 138 | 138 |
end |
| 139 |
save_revision_branches(rev) |
|
| 139 | 140 |
h["branches"][br]["last_scmid"] = rev.scmid |
| 140 | 141 |
merge_extra_info(h) |
| 141 | 142 |
self.save |
| ... | ... | |
| 144 | 145 |
end |
| 145 | 146 |
end |
| 146 | 147 | |
| 148 |
def save_revision_branches(rev) |
|
| 149 |
db_rev = find_changeset_by_name(rev.scmid) |
|
| 150 |
unless db_rev.nil? |
|
| 151 |
branches = scm.revision_branches(rev.scmid) |
|
| 152 |
unless branches.nil? |
|
| 153 |
db_rev.branches = branches.join(',')
|
|
| 154 |
db_rev.save |
|
| 155 |
end |
|
| 156 |
end |
|
| 157 |
end |
|
| 158 | ||
| 147 | 159 |
def save_revision(rev) |
| 148 | 160 |
changeset = Changeset.new( |
| 149 | 161 |
:repository => self, |
| app/views/issues/_changesets.rhtml (working copy) | ||
|---|---|---|
| 1 | 1 |
<% changesets.each do |changeset| %> |
| 2 | 2 |
<div class="changeset <%= cycle('odd', 'even') %>">
|
| 3 | 3 |
<p><%= link_to_revision(changeset, changeset.project, |
| 4 |
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %><br />
|
|
| 4 |
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
|
|
| 5 |
<% if changeset.branches? %> |
|
| 6 |
<span style="float:right;"><%= changeset.branches.split(',').collect{ |branch|
|
|
| 7 |
changeset.repository.branches.include?(branch) ? |
|
| 8 |
link_to_repository(branch, changeset.project, :text => branch) : nil }.compact.join(' / ') %></span>
|
|
| 9 |
<% end %> |
|
| 10 |
<br /> |
|
| 5 | 11 |
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> |
| 6 | 12 |
<div class="wiki"> |
| 7 | 13 |
<%= textilizable(changeset, :comments) %> |
| db/migrate/20111012193800_add_changesets_branches.rb (revision 0) | ||
|---|---|---|
| 1 |
class AddChangesetsBranches < ActiveRecord::Migration |
|
| 2 |
def self.up |
|
| 3 |
add_column :changesets, :branches, :string, :limit => nil, :default => nil |
|
| 4 |
end |
|
| 5 | ||
| 6 |
def self.down |
|
| 7 |
remove_column :changesets, :branches |
|
| 8 |
end |
|
| 9 |
end |
|
| lib/redmine/scm/adapters/git_adapter.rb (working copy) | ||
|---|---|---|
| 281 | 281 |
revs |
| 282 | 282 |
end |
| 283 | 283 | |
| 284 |
def revision_branches(identifier) |
|
| 285 |
cmd_args = %w|branch --contains| |
|
| 286 |
cmd_args << identifier |
|
| 287 |
branches = [] |
|
| 288 |
scm_cmd(*cmd_args) do |io| |
|
| 289 |
io.each_line do |line| |
|
| 290 |
branches << line.match('\s*\*?\s*(.*)$')[1]
|
|
| 291 |
end |
|
| 292 |
end |
|
| 293 |
branches.sort! |
|
| 294 |
rescue ScmCommandAborted |
|
| 295 |
nil |
|
| 296 |
end |
|
| 297 | ||
| 284 | 298 |
def diff(path, identifier_from, identifier_to=nil) |
| 285 | 299 |
path ||= '' |
| 286 | 300 |
cmd_args = [] |