Index: app/helpers/application_helper.rb =================================================================== --- app/helpers/application_helper.rb (revision 6453) +++ app/helpers/application_helper.rb (working copy) @@ -110,6 +110,13 @@ :title => l(:label_revision_id, format_revision(revision))) end + # Generates a link to a SCM repository + def link_to_repository(rev, project, options={}) + text = options.delete(:text) || rev + link_to(text, {:controller => 'repositories', :action => 'show', :id => project, :rev => rev}, + :title => rev) + end + # Generates a link to a message def link_to_message(message, options={}, html_options = nil) link_to( Index: app/models/repository/git.rb =================================================================== --- app/models/repository/git.rb (revision 6453) +++ app/models/repository/git.rb (working copy) @@ -136,6 +136,7 @@ if db_rev.nil? save_revision(rev) end + save_revision_branches(rev) h["branches"][br]["last_scmid"] = rev.scmid merge_extra_info(h) self.save @@ -144,6 +145,17 @@ end end + def save_revision_branches(rev) + db_rev = find_changeset_by_name(rev.scmid) + unless db_rev.nil? + branches = scm.revision_branches(rev.scmid) + unless branches.nil? + db_rev.branches = branches.join(',') + db_rev.save + end + end + end + def save_revision(rev) changeset = Changeset.new( :repository => self, Index: app/views/issues/_changesets.rhtml =================================================================== --- app/views/issues/_changesets.rhtml (revision 6453) +++ app/views/issues/_changesets.rhtml (working copy) @@ -1,7 +1,13 @@ <% changesets.each do |changeset| %>

<%= link_to_revision(changeset, changeset.project, - :text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
+ :text => "#{l(:label_revision)} #{changeset.format_identifier}") %> + <% if changeset.branches? %> + <%= changeset.branches.split(',').collect{ |branch| + changeset.repository.branches.include?(branch) ? + link_to_repository(branch, changeset.project, :text => branch) : nil }.compact.join(' / ') %> + <% end %> +
<%= authoring(changeset.committed_on, changeset.author) %>

<%= textilizable(changeset, :comments) %> Index: db/migrate/20111012193800_add_changesets_branches.rb =================================================================== --- db/migrate/20111012193800_add_changesets_branches.rb (revision 0) +++ db/migrate/20111012193800_add_changesets_branches.rb (revision 0) @@ -0,0 +1,9 @@ +class AddChangesetsBranches < ActiveRecord::Migration + def self.up + add_column :changesets, :branches, :string, :limit => nil, :default => nil + end + + def self.down + remove_column :changesets, :branches + end +end Index: lib/redmine/scm/adapters/git_adapter.rb =================================================================== --- lib/redmine/scm/adapters/git_adapter.rb (revision 6453) +++ lib/redmine/scm/adapters/git_adapter.rb (working copy) @@ -281,6 +281,20 @@ revs end + def revision_branches(identifier) + cmd_args = %w|branch --contains| + cmd_args << identifier + branches = [] + scm_cmd(*cmd_args) do |io| + io.each_line do |line| + branches << line.match('\s*\*?\s*(.*)$')[1] + end + end + branches.sort! + rescue ScmCommandAborted + nil + end + def diff(path, identifier_from, identifier_to=nil) path ||= '' cmd_args = []