File tree 3 files changed +26
-3
lines changed
3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1108,9 +1108,10 @@ def all_pipelines(shas: all_commit_shas)
1108
1108
end
1109
1109
1110
1110
def update_head_pipeline
1111
- self . head_pipeline = find_actual_head_pipeline
1112
-
1113
- update_column ( :head_pipeline_id , head_pipeline . id ) if head_pipeline_id_changed?
1111
+ find_actual_head_pipeline . try do |pipeline |
1112
+ self . head_pipeline = pipeline
1113
+ update_column ( :head_pipeline_id , head_pipeline . id ) if head_pipeline_id_changed?
1114
+ end
1114
1115
end
1115
1116
1116
1117
def merge_request_pipeline_exists?
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Fix unexpected exception by failure of finding an actual head pipeline
3
+ merge_request : 24257
4
+ author :
5
+ type : fixed
Original file line number Diff line number Diff line change @@ -1418,6 +1418,23 @@ def set_compare(merge_request)
1418
1418
. to change { merge_request . reload . head_pipeline }
1419
1419
. from ( nil ) . to ( pipeline )
1420
1420
end
1421
+
1422
+ context 'when merge request has already had head pipeline' do
1423
+ before do
1424
+ merge_request . update! ( head_pipeline : pipeline )
1425
+ end
1426
+
1427
+ context 'when failed to find an actual head pipeline' do
1428
+ before do
1429
+ allow ( merge_request ) . to receive ( :find_actual_head_pipeline ) { }
1430
+ end
1431
+
1432
+ it 'does not update the current head pipeline' do
1433
+ expect { subject }
1434
+ . not_to change { merge_request . reload . head_pipeline }
1435
+ end
1436
+ end
1437
+ end
1421
1438
end
1422
1439
1423
1440
context 'when there are no pipelines with the diff head sha' do
You can’t perform that action at this time.
0 commit comments