This instance will be upgraded to Heptapod 0.27.1 on 2021-12-08 at 22:00 UTC+1 (a few minutes of down time)

Commit 52a259dd authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Revert "Merge branch 'fix-latest-pipeine-ordering' into 'master'"

This reverts merge request !8286
parent d9833f6cc1b6
......@@ -93,8 +93,11 @@ class Pipeline < ActiveRecord::Base
.select("max(#{quoted_table_name}.id)")
.group(:ref, :sha)
relation = ref ? where(ref: ref) : self
relation.where(id: max_id).order(id: :desc)
if ref
where(id: max_id, ref: ref)
else
where(id: max_id)
end
end
def self.latest_status(ref = nil)
......
......@@ -418,7 +418,7 @@ def commit(ref = 'HEAD')
repository.commit(ref)
end
# ref can't be HEAD or SHA, can only be branch/tag name
# ref can't be HEAD, can only be branch/tag name or SHA
def latest_successful_builds_for(ref = default_branch)
latest_pipeline = pipelines.latest_successful_for(ref)
......
---
title: Fix finding the latest pipeline
merge_request: 8286
author:
......@@ -424,18 +424,20 @@ def create_pipeline(status, ref, sha)
context 'when no ref is specified' do
let(:pipelines) { described_class.latest.all }
it 'gives the latest pipelines for the same ref and different sha in reverse chronological order' do
expect(pipelines.map(&:sha)).to eq(%w[C B A])
expect(pipelines.map(&:status)).to eq(%w[skipped failed success])
it 'returns the latest pipeline for the same ref and different sha' do
expect(pipelines.map(&:sha)).to contain_exactly('A', 'B', 'C')
expect(pipelines.map(&:status)).
to contain_exactly('success', 'failed', 'skipped')
end
end
context 'when ref is specified' do
let(:pipelines) { described_class.latest('ref').all }
it 'gives the latest pipelines for ref and different sha in reverse chronological order' do
expect(pipelines.map(&:sha)).to eq(%w[B A])
expect(pipelines.map(&:status)).to eq(%w[failed success])
it 'returns the latest pipeline for ref and different sha' do
expect(pipelines.map(&:sha)).to contain_exactly('A', 'B')
expect(pipelines.map(&:status)).
to contain_exactly('success', 'failed')
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