Commit 5a2c8480 authored by Stan Hu's avatar Stan Hu

Merge branch 'ignore-new-line-differences' into 'master'

Ignore new line differences when deciding whether to squash MR

See merge request gitlab-org/gitlab!77429
parents 8e805846 7b38fbee
...@@ -5,7 +5,7 @@ module MergeRequests ...@@ -5,7 +5,7 @@ module MergeRequests
def execute def execute
# If performing a squash would result in no change, then # If performing a squash would result in no change, then
# immediately return a success message without performing a squash # immediately return a success message without performing a squash
if merge_request.commits_count == 1 && message == merge_request.first_commit.safe_message if merge_request.commits_count == 1 && message&.strip == merge_request.first_commit.safe_message&.strip
return success(squash_sha: merge_request.diff_head_sha) return success(squash_sha: merge_request.diff_head_sha)
end end
......
...@@ -76,6 +76,22 @@ RSpec.describe MergeRequests::SquashService do ...@@ -76,6 +76,22 @@ RSpec.describe MergeRequests::SquashService do
service.execute service.execute
end end
end end
context 'when squash message matches commit message but without trailing new line' do
let(:service) { described_class.new(project: project, current_user: user, params: { merge_request: merge_request, squash_commit_message: merge_request.first_commit.safe_message.strip }) }
it 'returns that commit SHA' do
result = service.execute
expect(result).to match(status: :success, squash_sha: merge_request.diff_head_sha)
end
it 'does not perform any git actions' do
expect(repository).not_to receive(:squash)
service.execute
end
end
end end
context 'the squashed commit' do context 'the squashed commit' 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