Browse Source

Adds a setting to enable/disable formatting of commit messages (#22758).

git-svn-id: http://svn.redmine.org/redmine/trunk@16062 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 7 years ago
parent
commit
ba2a47a8fb

+ 12
- 1
app/helpers/application_helper.rb View File

@@ -254,6 +254,11 @@ module ApplicationHelper
end
end

def format_changeset_comments(changeset, options={})
method = options[:short] ? :short_comments : :comments
textilizable changeset, method, :formatting => Setting.commit_logs_formatting?
end

def due_date_distance_in_words(date)
if date
l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date))
@@ -619,7 +624,13 @@ module ApplicationHelper

text = text.dup
macros = catch_macros(text)
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)

if options[:formatting] == false
text = h(text)
else
formatting = options[:formatting] || Setting.text_formatting
text = Redmine::WikiFormatting.to_html(formatting, text, :object => obj, :attribute => attr)
end

@parsed_headings = []
@heading_anchors = {}

+ 2
- 2
app/views/issues/_changesets.html.erb View File

@@ -13,8 +13,8 @@
<% end %>
<br />
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p>
<div class="wiki">
<%= textilizable(changeset, :comments) %>
<div class="wiki changset-comments">
<%= format_changeset_comments changeset %>
</div>
</div>
<% end %>

+ 3
- 1
app/views/repositories/_changeset.html.erb View File

@@ -33,7 +33,9 @@

</div>

<%= textilizable @changeset.comments %>
<div class="wiki changset-comments">
<%= format_changeset_comments @changeset %>
</div>

<% if @changeset.issues.visible.any? || User.current.allowed_to?(:manage_related_issues, @repository.project) %>
<%= render :partial => 'related_issues' %>

+ 1
- 1
app/views/repositories/_revisions.html.erb View File

@@ -42,7 +42,7 @@ end %>
<td class="checkbox"><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').prop('checked')) {$('#cb-#{line_num-1}').prop('checked',true);}") if show_diff && (line_num > 1) %></td>
<td class="committed_on"><%= format_time(changeset.committed_on) %></td>
<td class="author"><%= changeset.user.blank? ? changeset.author.to_s.truncate(30) : link_to_user(changeset.user) %></td>
<td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td>
<td class="comments"><%= format_changeset_comments changeset, :short => true %></td>
</tr>
<% line_num += 1 %>
<% end %>

+ 2
- 0
app/views/settings/_repositories.html.erb View File

@@ -52,6 +52,8 @@
</p>

<p><%= setting_text_field :repository_log_display_limit, :size => 6 %></p>

<p><%= setting_check_box :commit_logs_formatting %></p>
</div>

<fieldset class="box tabular settings">

+ 1
- 0
config/locales/en.yml View File

@@ -448,6 +448,7 @@ en:
setting_attachment_extensions_allowed: Allowed extensions
setting_attachment_extensions_denied: Disallowed extensions
setting_new_item_menu_tab: Project menu tab for creating new objects
setting_commit_logs_formatting: Apply text formatting to commit messages

permission_add_project: Create project
permission_add_subprojects: Create subprojects

+ 1
- 0
config/locales/fr.yml View File

@@ -460,6 +460,7 @@ fr:
setting_sys_api_key: Clé de protection de l'API
setting_lost_password: Autoriser la réinitialisation par email de mot de passe perdu
setting_new_item_menu_tab: Onglet de création d'objets dans le menu du project
setting_commit_logs_formatting: Appliquer le formattage de texte aux messages de commit

permission_add_project: Créer un projet
permission_add_subprojects: Créer des sous-projets

+ 2
- 0
config/settings.yml View File

@@ -239,6 +239,8 @@ repositories_encodings:
# encoding used to convert commit logs to UTF-8
commit_logs_encoding:
default: 'UTF-8'
commit_logs_formatting:
default: 1
repository_log_display_limit:
format: int
default: 100

+ 1
- 0
public/stylesheets/application.css View File

@@ -492,6 +492,7 @@ div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 1
div#issue-changesets div.changeset { padding: 4px;}
div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; }
div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}
.changset-comments {margin-bottom:1em; font-family:}

div.journal {overflow:auto;}
div.journal.private-notes {border-left:2px solid #d22; padding-left:4px; margin-left:-6px;}

+ 10
- 0
test/functional/repositories_controller_test.rb View File

@@ -167,6 +167,16 @@ class RepositoriesControllerTest < Redmine::ControllerTest
assert_select 'h2', :text => 'Revision 1'
end

def test_revision_should_not_format_comments_when_disabled
Changeset.where(:id => 100).update_all(:comments => 'Simple *text*')

with_settings :commit_logs_formatting => '0' do
get :revision, :id => 1, :rev => 1
assert_response :success
assert_select '.changset-comments', :text => 'Simple *text*'
end
end

def test_revision_should_show_add_related_issue_form
Role.find(1).add_permission! :manage_related_issues
@request.session[:user_id] = 2

Loading…
Cancel
Save