Commit cb3988ae authored by Tomas Vik (OOO back on 2026-08-31)'s avatar Tomas Vik (OOO back on 2026-08-31) 🌴
Browse files

fix: reorder pipelines to fix GitLab ordering issue

parent 377f9baa
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import { DEFAULT_FETCH_RESPONSE } from '../__mocks__/cross-fetch';
import { CustomQueryType } from './custom_query_type';
import { CustomQuery } from './custom_query';
import { asMock } from '../test_utils/as_mock';
import { externalStatus, gqlProject, project } from '../test_utils/entities';
import { externalStatus, gqlProject, mr, pipeline, project } from '../test_utils/entities';
import { getExtensionConfiguration } from '../utils/extension_configuration';
import { getHttpAgentOptions } from './http/get_http_agent_options';
import { HelpError } from '../errors/help_error';
@@ -134,6 +134,21 @@ describe('gitlab_service', () => {
    });
  });

  describe('getLastPipelineForMr', () => {
    it('returns pipeline with largest iid', async () => {
      asMock(crossFetch).mockReturnValue(
        crossFetchResponse([
          { ...pipeline, iid: 1 },
          { ...pipeline, iid: 2 },
        ]),
      );

      const result = await service.getLastPipelineForMr(mr);

      expect(result!.iid).toBe(2);
    });
  });

  describe('getFile', () => {
    it('constructs the correct URL', async () => {
      await service.getFile('foo', 'bar', 12345);
+4 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import { HelpError } from '../errors/help_error';
import { Credentials } from '../accounts/credentials';
import { newCreateNoteMutation, oldCreateNoteMutation } from './graphql/create_note';
import { createQueryString, QueryValue } from '../utils/create_query_string';
import { sort } from '../utils/sort';

interface CreateNoteResult {
  createNote: {
@@ -936,7 +937,9 @@ export class GitLabService {
      {},
      'pipelines for MR',
    );
    return pipelines[0];
    // the sort is a fix for an ordering issue https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/issues/569
    // the sort can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/344853 is fixed
    return sort(pipelines, (p1, p2) => p2.iid - p1.iid)[0];
  }

  async getOpenMergeRequestForCurrentBranch(
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ export const pipeline: RestPipeline = {
  status: 'success',
  updated_at: '2021-02-12T12:06:17Z',
  id: 123456,
  iid: 1,
  project_id: 567890,
  sha: 'aaaaaaaa',
  ref: 'main',
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ interface RestPipeline {
    | 'preparing';
  updated_at: string;
  id: number;
  iid: number;
  ref: string | null;
  sha: string;
  /**