Patch #7959 ยป revision-update-1.1.0.patch
| redmine-1.1.0-revision-update/app/controllers/repositories_controller.rb 2011-03-22 12:01:56.115467800 -0600 | ||
|---|---|---|
| 150 | 150 |
show_error_not_found |
| 151 | 151 |
end |
| 152 | 152 |
|
| 153 |
def update #revision |
|
| 154 |
@changeset = @repository.find_changeset_by_name(@rev) |
|
| 155 |
raise ChangesetNotFound unless @changeset |
|
| 156 |
|
|
| 157 |
# update revision properties from repository |
|
| 158 |
revision = @repository.scm.revision(@rev) |
|
| 159 |
@changeset.committer = revision.author |
|
| 160 |
@changeset.committed_on = revision.time |
|
| 161 |
@changeset.comments = revision.message |
|
| 162 |
|
|
| 163 |
# report success or errors |
|
| 164 |
if @changeset.save |
|
| 165 |
flash[:notice] = l(:notice_successful_update) |
|
| 166 |
# on success, rescan new comments for related issue ids |
|
| 167 |
@changeset.scan_comment_for_issue_ids |
|
| 168 |
else |
|
| 169 |
# can't seem to bring in the helper method 'error_messages_for' |
|
| 170 |
# and injecting it into show.rhtml doesn't seem to work, since |
|
| 171 |
# the @changeset loses the errors on redirect (due to changeset reload) |
|
| 172 |
flash[:error] = "<ul>" + @changeset.errors.full_messages.map {|msg| "<li>" + ERB::Util.html_escape(msg) + "</li>"}.join + "</ul>"
|
|
| 173 |
end |
|
| 174 |
|
|
| 175 |
respond_to do |format| |
|
| 176 |
format.html { redirect_to :action => 'revision', :id => @project, :rev => @rev }
|
|
| 177 |
format.api { render_validation_errors(@changeset) }
|
|
| 178 |
end |
|
| 179 |
|
|
| 180 |
rescue ChangesetNotFound |
|
| 181 |
show_error_not_found |
|
| 182 |
end |
|
| 183 |
|
|
| 153 | 184 |
def diff |
| 154 | 185 |
if params[:format] == 'diff' |
| 155 | 186 |
@diff = @repository.diff(@path, @rev, @rev_to) |
| redmine-1.1.0-revision-update/app/models/changeset.rb 2011-03-22 12:03:22.319144500 -0600 | ||
|---|---|---|
| 125 | 125 |
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] |
| 126 | 126 |
if issue |
| 127 | 127 |
referenced_issues << issue |
| 128 |
fix_issue(issue) if fix_keywords.include?(action.to_s.downcase) |
|
| 129 |
log_time(issue, hours) if hours && Setting.commit_logtime_enabled? |
|
| 128 |
# don't update the issue if a relation already exists |
|
| 129 |
if !self.issues.include?(issue) |
|
| 130 |
fix_issue(issue) if fix_keywords.include?(action.to_s.downcase) |
|
| 131 |
log_time(issue, hours) if hours && Setting.commit_logtime_enabled? |
|
| 132 |
end |
|
| 130 | 133 |
end |
| 131 | 134 |
end |
| 132 | 135 |
end |
| redmine-1.1.0-revision-update/app/views/repositories/revision.rhtml 2011-03-22 12:01:56.146718000 -0600 | ||
|---|---|---|
| 19 | 19 |
<% end %> |
| 20 | 20 |
</div> |
| 21 | 21 |
|
| 22 |
<h2><%= l(:label_revision) %> <%= format_revision(@changeset) %></h2> |
|
| 22 |
<h2> |
|
| 23 |
<%= l(:label_revision) %> <%= format_revision(@changeset) %> |
|
| 24 |
<%= link_to(image_tag('reload.png'), {:controller => 'repositories', :action => 'update', :id => @project, :rev => @rev}, :method => :get, :title => l(:button_update)) %>
|
|
| 25 |
</h2> |
|
| 23 | 26 |
|
| 24 | 27 |
<p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> |
| 25 | 28 |
<span class="author"><%= authoring(@changeset.committed_on, @changeset.author) %></span></p> |
| ... | ... | |
| 45 | 48 |
<li class="change change-D"><%= l(:label_deleted) %></li> |
| 46 | 49 |
</ul> |
| 47 | 50 |
|
| 48 |
<p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.identifier) if @changeset.changes.any? %></p>
|
|
| 51 |
<p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @rev) if @changeset.changes.any? %></p>
|
|
| 49 | 52 |
|
| 50 | 53 |
<div class="changeset-changes"> |
| 51 | 54 |
<%= render_changeset_changes %> |
| redmine-1.1.0-revision-update/lib/redmine/scm/adapters/abstract_adapter.rb 2011-03-22 12:01:56.146718000 -0600 | ||
|---|---|---|
| 117 | 117 |
return nil |
| 118 | 118 |
end |
| 119 | 119 |
|
| 120 |
def revision(identifier) |
|
| 121 |
revisions = revisions(nil, identifier, identifier, {})
|
|
| 122 |
return nil unless revisions |
|
| 123 |
return revisions.first |
|
| 124 |
end |
|
| 125 |
|
|
| 120 | 126 |
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
|
| 121 | 127 |
return nil |
| 122 | 128 |
end |
| redmine-1.1.0-revision-update/lib/redmine.rb 2011-03-22 12:01:56.162343100 -0600 | ||
|---|---|---|
| 120 | 120 |
end |
| 121 | 121 |
|
| 122 | 122 |
map.project_module :repository do |map| |
| 123 |
map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
|
|
| 123 |
map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy, :update]}, :require => :member
|
|
| 124 | 124 |
map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
| 125 | 125 |
map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
| 126 | 126 |
map.permission :commit_access, {}
|