Commit 02f99edf authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'changelog-commits-without-description' into 'master'

Handle commits without descriptions for changelogs

See merge request gitlab-org/gitlab!56224
parents 10736e4f a3b9856e
......@@ -93,7 +93,7 @@ module Repositories
end
def revert_commit_sha(commit)
matches = commit.description.match(REVERT_REGEX)
matches = commit.description&.match(REVERT_REGEX)
matches[:sha] if matches
end
......
---
title: Handle commits without descriptions for changelogs
merge_request: 56224
author:
type: fixed
......@@ -64,4 +64,30 @@ RSpec.describe Repositories::ChangelogCommitsFinder do
expect(commits.count).to eq(4)
end
end
describe '#revert_commit_sha' do
let(:finder) { described_class.new(project: project, from: 'a', to: 'b') }
it 'returns the SHA of a reverted commit' do
commit = double(
:commit,
description: 'This reverts commit 152c03af1b09f50fa4b567501032b106a3a81ff3.'
)
expect(finder.send(:revert_commit_sha, commit))
.to eq('152c03af1b09f50fa4b567501032b106a3a81ff3')
end
it 'returns nil when the commit is not a revert commit' do
commit = double(:commit, description: 'foo')
expect(finder.send(:revert_commit_sha, commit)).to be_nil
end
it 'returns nil when the commit has no description' do
commit = double(:commit, description: nil)
expect(finder.send(:revert_commit_sha, commit)).to be_nil
end
end
end
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