Commit 8c4a3c77 authored by Minsik Yoon's avatar Minsik Yoon

Add ignore whitespace change option to commit view

parent d73d2a5e
...@@ -7,6 +7,7 @@ v 8.3.0 (unreleased) ...@@ -7,6 +7,7 @@ v 8.3.0 (unreleased)
- Fix 500 error when update group member permission - Fix 500 error when update group member permission
- Fix: Raw private snippets access workflow - Fix: Raw private snippets access workflow
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera) - Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
- Add ignore whitespace change option to commit view
v 8.2.1 v 8.2.1
- Forcefully update builds that didn't want to update with state machine - Forcefully update builds that didn't want to update with state machine
......
...@@ -67,7 +67,12 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -67,7 +67,12 @@ class Projects::CommitController < Projects::ApplicationController
end end
def define_show_vars def define_show_vars
if params[:w].to_i == 1
@diffs = commit.diffs({ ignore_whitespace_change: true })
else
@diffs = commit.diffs @diffs = commit.diffs
end
@notes_count = commit.notes.count @notes_count = commit.notes.count
@builds = ci_commit.builds if ci_commit @builds = ci_commit.builds if ci_commit
......
...@@ -69,6 +69,21 @@ describe Projects::CommitController do ...@@ -69,6 +69,21 @@ describe Projects::CommitController do
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
it "should really only be a git diff without whitespace changes" do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: '66eceea0db202bb39c4e445e8ca28689645366c5',
# id: commit.id,
format: format,
w: 1)
expect(response.body).to start_with("diff --git")
# without whitespace option, there are more than 2 diff_splits
diff_splits = assigns(:diffs)[0].diff.split("\n")
expect(diff_splits.length).to be <= 2
end
end end
describe "as patch" do describe "as patch" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment