Index: app/helpers/application_helper.rb ======================================================================== --- app/helpers/application_helper.rb Fri Apr 05 09:59:21 2013 +0000 +++ app/helpers/application_helper.rb Wed May 22 23:25:08 2013 +0200 @@ -113,6 +113,13 @@ ) 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 Fri Apr 05 09:59:21 2013 +0000 +++ app/models/repository/git.rb Wed May 22 23:25:08 2013 +0200 @@ -209,6 +209,7 @@ # There is no search in the db for this revision, because above we ensured, # that it's not in the db. save_revision(rev) + save_revision_branches(rev) end end h["heads"] = repo_heads.dup @@ -217,6 +218,18 @@ end private :save_revisions + 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 + private :save_revision_branches + def save_revision(rev) parents = (rev.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact changeset = Changeset.create( Index: app/views/issues/_changesets.html.erb ================================================================================ --- app/views/issues/_changesets.html.erb Fri Apr 05 09:59:21 2013 +0000 +++ app/views/issues/_changesets.html.erb Wed May 22 23:25:08 2013 +0200 @@ -1,7 +1,16 @@ <% changesets.each do |changeset| %>

<%= link_to_revision(changeset, changeset.repository, - :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 Thu Jan 01 00:00:00 1970 +0000 +++ db/migrate/20111012193800_add_changesets_branches.rb Wed May 22 23:25:08 2013 +0200 @@ -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 Fri Apr 05 09:59:21 2013 +0000 +++ lib/redmine/scm/adapters/git_adapter.rb Wed May 22 23:25:08 2013 +0200 @@ -311,6 +311,20 @@ end end + def revision_branches(identifier) + cmd_args = %w|branch --contains| + cmd_args << identifier + branches = [] + git_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 = []