Feature #5386 » 5386-branches-in-associated-revisions-2.3-stable.diff
| app/helpers/application_helper.rb Wed May 22 23:25:08 2013 +0200 | ||
|---|---|---|
|
)
|
||
|
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(
|
||
| app/models/repository/git.rb Wed May 22 23:25:08 2013 +0200 | ||
|---|---|---|
|
# 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
|
||
| ... | ... | |
|
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(
|
||
| app/views/issues/_changesets.html.erb Wed May 22 23:25:08 2013 +0200 | ||
|---|---|---|
|
<% changesets.each do |changeset| %>
|
||
|
<div class="changeset <%= cycle('odd', 'even') %>">
|
||
|
<p><%= link_to_revision(changeset, changeset.repository,
|
||
|
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %><br />
|
||
|
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
|
||
|
<% if changeset.branches? %>
|
||
|
<span style="float: right;">
|
||
|
<%== changeset.branches.split(',').collect{ |branch|
|
||
|
changeset.repository.branches.include?(branch) ?
|
||
|
link_to_repository(branch, changeset.project, :text => branch) : nil }.compact.join(' / ') %>
|
||
|
</span>
|
||
|
<% end %>
|
||
|
<br />
|
||
|
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p>
|
||
|
<div class="wiki">
|
||
|
<%= textilizable(changeset, :comments) %>
|
||
| db/migrate/20111012193800_add_changesets_branches.rb Wed May 22 23:25:08 2013 +0200 | ||
|---|---|---|
|
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
|
||
| lib/redmine/scm/adapters/git_adapter.rb Wed May 22 23:25:08 2013 +0200 | ||
|---|---|---|
|
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 = []
|
||