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

end end
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) def due_date_distance_in_words(date)
if date if date
l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date)) l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date))


text = text.dup text = text.dup
macros = catch_macros(text) 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 = [] @parsed_headings = []
@heading_anchors = {} @heading_anchors = {}

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

<% end %> <% end %>
<br /> <br />
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> <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>
</div> </div>
<% end %> <% end %>

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



</div> </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) %> <% if @changeset.issues.visible.any? || User.current.allowed_to?(:manage_related_issues, @repository.project) %>
<%= render :partial => 'related_issues' %> <%= render :partial => 'related_issues' %>

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

<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="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="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="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> </tr>
<% line_num += 1 %> <% line_num += 1 %>
<% end %> <% end %>

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

</p> </p>


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

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


<fieldset class="box tabular settings"> <fieldset class="box tabular settings">

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

setting_attachment_extensions_allowed: Allowed extensions setting_attachment_extensions_allowed: Allowed extensions
setting_attachment_extensions_denied: Disallowed extensions setting_attachment_extensions_denied: Disallowed extensions
setting_new_item_menu_tab: Project menu tab for creating new objects 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_project: Create project
permission_add_subprojects: Create subprojects permission_add_subprojects: Create subprojects

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

setting_sys_api_key: Clé de protection de l'API 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_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_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_project: Créer un projet
permission_add_subprojects: Créer des sous-projets permission_add_subprojects: Créer des sous-projets

+ 2
- 0
config/settings.yml View File

# encoding used to convert commit logs to UTF-8 # encoding used to convert commit logs to UTF-8
commit_logs_encoding: commit_logs_encoding:
default: 'UTF-8' default: 'UTF-8'
commit_logs_formatting:
default: 1
repository_log_display_limit: repository_log_display_limit:
format: int format: int
default: 100 default: 100

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

div#issue-changesets div.changeset { padding: 4px;} div#issue-changesets div.changeset { padding: 4px;}
div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; } div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; }
div#issue-changesets p { margin-top: 0; margin-bottom: 1em;} div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}
.changset-comments {margin-bottom:1em; font-family:}


div.journal {overflow:auto;} div.journal {overflow:auto;}
div.journal.private-notes {border-left:2px solid #d22; padding-left:4px; margin-left:-6px;} 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

assert_select 'h2', :text => 'Revision 1' assert_select 'h2', :text => 'Revision 1'
end 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 def test_revision_should_show_add_related_issue_form
Role.find(1).add_permission! :manage_related_issues Role.find(1).add_permission! :manage_related_issues
@request.session[:user_id] = 2 @request.session[:user_id] = 2

Loading…
Cancel
Save