From ccb5cd6f7732d37cd6115a3140321f3a1480f1b0 Mon Sep 17 00:00:00 2001 From: Plai Date: Mon, 16 Oct 2023 15:44:54 +0700 Subject: [PATCH] Use first diff version if there's no collected diff ver (#155) Co-authored-by: pdujtipiya --- src/Provider/GitLab/GitLabMRService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Provider/GitLab/GitLabMRService.ts b/src/Provider/GitLab/GitLabMRService.ts index 95c56f2..e8e8c49 100644 --- a/src/Provider/GitLab/GitLabMRService.ts +++ b/src/Provider/GitLab/GitLabMRService.ts @@ -10,6 +10,7 @@ import * as Resources from '@gitbeaker/core'; import { Gitlab } from '@gitbeaker/rest'; import { configs } from '../../Config'; +import { Log } from '../../Logger'; export class GitLabMRService implements IGitLabMRService { private readonly projectId: number; @@ -86,7 +87,12 @@ export class GitLabMRService implements IGitLabMRService { ); const collected = versions.filter((v) => v.state === 'collected'); - if (collected.length === 0) throw new Error('No collected version in MR'); + if (collected.length === 0) { + Log.warn( + 'No collected version in this MR, will use SHA from the latest commit instead.', + ); + return versions[0]; + } return collected[0]; }