From d9ecaee5f58b1b94413903ebf737b4d235bc2858 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <git@minelli.swiss>
Date: Mon, 7 Oct 2024 17:53:17 +0200
Subject: [PATCH] SharedAssignmentHelper => Add a init function with
 gitlabManager

---
 helpers/Dojo/SharedAssignmentHelper.ts | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/helpers/Dojo/SharedAssignmentHelper.ts b/helpers/Dojo/SharedAssignmentHelper.ts
index d57caab..c193088 100644
--- a/helpers/Dojo/SharedAssignmentHelper.ts
+++ b/helpers/Dojo/SharedAssignmentHelper.ts
@@ -3,10 +3,16 @@ import DojoStatusCode       from '../../types/Dojo/DojoStatusCode.js';
 import Json5FileValidator   from '../Json5FileValidator.js';
 import * as Gitlab          from '@gitbeaker/rest';
 import GitlabPipelineStatus from '../../types/Gitlab/GitlabPipelineStatus.js';
-import GitlabManager        from '../../../managers/GitlabManager.js';
+import SharedGitlabManager  from '../../managers/SharedGitlabManager';
 
 
 class SharedAssignmentHelper {
+    private gitlabManager!: SharedGitlabManager;
+
+    init(gitlabManager: SharedGitlabManager) {
+        this.gitlabManager = gitlabManager;
+    }
+
     validateDescriptionFile(filePathOrStr: string, isFile: boolean = true, version: number = 1): { content: AssignmentFile | undefined, isValid: boolean, error: string | null } {
         if ( version === 1 ) {
             return Json5FileValidator.validateFile(AssignmentFile, filePathOrStr, isFile);
@@ -20,7 +26,7 @@ class SharedAssignmentHelper {
     }
 
     async isPublishable(repositoryId: number): Promise<{ isPublishable: boolean, lastPipeline: Gitlab.PipelineSchema | null, status?: { code: DojoStatusCode, message: string } }> {
-        const pipelines = await GitlabManager.getRepositoryPipelines(repositoryId, 'main');
+        const pipelines = await this.gitlabManager.getRepositoryPipelines(repositoryId, 'main');
         if ( pipelines.length > 0 ) {
             const lastPipeline = pipelines[0];
             if ( lastPipeline.status !== GitlabPipelineStatus.SUCCESS.valueOf() ) {
-- 
GitLab