diff options
author | Minsik Yoon <yms9654@gmail.com> | 2015-11-30 18:30:44 +0900 |
---|---|---|
committer | Minsik Yoon <yms9654@gmail.com> | 2015-12-01 09:51:10 +0900 |
commit | 8c4a3c77d87e89bf3fd237fef49fc87fb6170d86 (patch) | |
tree | 51bb96b58e513daf35052db83650652dc3ac3b01 | |
parent | d73d2a5e5851dd97223705272f05a1e2a87ffb5d (diff) | |
download | gitlab-ce-8c4a3c77d87e89bf3fd237fef49fc87fb6170d86.tar.gz |
Add ignore whitespace change option to commit view
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 7 | ||||
-rw-r--r-- | spec/controllers/commit_controller_spec.rb | 15 |
3 files changed, 22 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 090b54f41a4..35bb9951d86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ v 8.3.0 (unreleased) - Fix 500 error when update group member permission - Fix: Raw private snippets access workflow - Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera) + - Add ignore whitespace change option to commit view v 8.2.1 - Forcefully update builds that didn't want to update with state machine diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index deefdd76667..3f137440e28 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -67,7 +67,12 @@ class Projects::CommitController < Projects::ApplicationController end def define_show_vars - @diffs = commit.diffs + if params[:w].to_i == 1 + @diffs = commit.diffs({ ignore_whitespace_change: true }) + else + @diffs = commit.diffs + end + @notes_count = commit.notes.count @builds = ci_commit.builds if ci_commit diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index bb3d87f3840..5337a69e84b 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -69,6 +69,21 @@ describe Projects::CommitController do expect(response.body).to start_with("diff --git") 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 describe "as patch" do |