Commit bd8fec17 authored by Kerri Miller's avatar Kerri Miller

Merge branch '270054-fix-no-method-error' into 'master'

Fix error when cleaning up MR with no head ref

See merge request gitlab-org/gitlab!45504
parents 3f1cbee6 72c84785
...@@ -17,7 +17,7 @@ module MergeRequests ...@@ -17,7 +17,7 @@ module MergeRequests
@repository = merge_request.project.repository @repository = merge_request.project.repository
@ref_path = merge_request.ref_path @ref_path = merge_request.ref_path
@merge_ref_path = merge_request.merge_ref_path @merge_ref_path = merge_request.merge_ref_path
@ref_head_sha = @repository.commit(merge_request.ref_path).id @ref_head_sha = @repository.commit(merge_request.ref_path)&.id
@merge_ref_sha = merge_request.merge_ref_head&.id @merge_ref_sha = merge_request.merge_ref_head&.id
end end
......
---
title: Fix error when cleaning up MR with no head ref
merge_request: 45504
author:
type: fixed
...@@ -35,6 +35,17 @@ RSpec.describe MergeRequests::CleanupRefsService do ...@@ -35,6 +35,17 @@ RSpec.describe MergeRequests::CleanupRefsService do
end end
end end
context 'when merge request has no head ref' do
before do
# Simulate a merge request with no head ref
merge_request.project.repository.delete_refs(merge_request.ref_path)
end
it 'does not fail' do
expect(result[:status]).to eq(:success)
end
end
context 'when merge request has merge ref' do context 'when merge request has merge ref' do
before do before do
MergeRequests::MergeToRefService MergeRequests::MergeToRefService
......
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