From 6866c8d964ca8b0e576a2df30daa4fb05a665d34 Mon Sep 17 00:00:00 2001 From: lstocchi Date: Tue, 30 Jan 2024 10:40:41 +0100 Subject: [PATCH] fix: use single ref field Signed-off-by: lstocchi --- packages/backend/src/ai.json | 6 ++---- .../src/managers/applicationManager.spec.ts | 21 +++++++------------ .../src/managers/applicationManager.ts | 3 +-- packages/backend/src/managers/gitManager.ts | 7 +++---- packages/shared/src/models/IRecipe.ts | 3 +-- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/packages/backend/src/ai.json b/packages/backend/src/ai.json index 807668be7..7b0dab948 100644 --- a/packages/backend/src/ai.json +++ b/packages/backend/src/ai.json @@ -5,8 +5,7 @@ "description" : "Chat bot application", "name" : "ChatBot", "repository": "https://github.com/redhat-et/locallm", - "branch": "main", - "sha": "bccd1c1", + "ref": "bccd1c1", "icon": "natural-language-processing", "categories": [ "natural-language-processing" @@ -22,8 +21,7 @@ "description" : "Summarizer application", "name" : "Summarizer", "repository": "https://github.com/redhat-et/locallm", - "branch": "main", - "sha": "bccd1c1", + "ref": "bccd1c1", "icon": "natural-language-processing", "categories": [ "natural-language-processing" diff --git a/packages/backend/src/managers/applicationManager.spec.ts b/packages/backend/src/managers/applicationManager.spec.ts index 0363e4a45..d3e7b6af3 100644 --- a/packages/backend/src/managers/applicationManager.spec.ts +++ b/packages/backend/src/managers/applicationManager.spec.ts @@ -165,8 +165,7 @@ describe('pullApplication', () => { name: 'Recipe 1', categories: [], description: '', - branch: 'branch', - sha: '000000', + ref: '000000', readme: '', repository: 'repo', }; @@ -187,9 +186,8 @@ describe('pullApplication', () => { }); await manager.pullApplication(recipe, model); const gitCloneOptions = { - branch: 'branch', repository: 'repo', - sha: '000000', + ref: '000000', targetDirectory: '\\home\\user\\aistudio\\recipe1', }; if (process.platform === 'win32') { @@ -211,8 +209,7 @@ describe('pullApplication', () => { name: 'Recipe 1', categories: [], description: '', - branch: 'branch', - sha: '000000', + ref: '000000', readme: '', repository: 'repo', }; @@ -239,8 +236,7 @@ describe('pullApplication', () => { id: 'recipe1', name: 'Recipe 1', categories: [], - branch: 'branch', - sha: '000000', + ref: '000000', description: '', readme: '', repository: 'repo', @@ -270,8 +266,7 @@ describe('pullApplication', () => { name: 'Recipe 1', categories: [], description: '', - branch: 'branch', - sha: '000000', + ref: '000000', readme: '', repository: 'repo', }; @@ -312,9 +307,8 @@ describe('doCheckout', () => { {} as unknown as ModelsManager, ); const gitCloneOptions = { - branch: 'branch', repository: 'repo', - sha: '000000', + ref: '000000', targetDirectory: 'folder', }; await manager.doCheckout(gitCloneOptions, taskUtils); @@ -348,8 +342,7 @@ describe('doCheckout', () => { await manager.doCheckout( { repository: 'repo', - branch: 'branch', - sha: '000000', + ref: '000000', targetDirectory: 'folder', }, taskUtils, diff --git a/packages/backend/src/managers/applicationManager.ts b/packages/backend/src/managers/applicationManager.ts index 7288ffcda..ecf4a0832 100644 --- a/packages/backend/src/managers/applicationManager.ts +++ b/packages/backend/src/managers/applicationManager.ts @@ -90,8 +90,7 @@ export class ApplicationManager { // clone the recipe repository on the local folder const gitCloneInfo: GitCloneInfo = { repository: recipe.repository, - branch: recipe.branch, - sha: recipe.sha, + ref: recipe.ref, targetDirectory: localFolder, }; await this.doCheckout(gitCloneInfo, taskUtil); diff --git a/packages/backend/src/managers/gitManager.ts b/packages/backend/src/managers/gitManager.ts index 0a399a012..505383a94 100644 --- a/packages/backend/src/managers/gitManager.ts +++ b/packages/backend/src/managers/gitManager.ts @@ -20,16 +20,15 @@ import simpleGit from 'simple-git'; export interface GitCloneInfo { repository: string; - branch: string; - sha: string; + ref: string; targetDirectory: string; } export class GitManager { async cloneRepository(gitCloneInfo: GitCloneInfo) { // clone repo - await simpleGit().clone(gitCloneInfo.repository, gitCloneInfo.targetDirectory, ['-b', gitCloneInfo.branch]); + await simpleGit().clone(gitCloneInfo.repository, gitCloneInfo.targetDirectory); // checkout to specific branch - await simpleGit(gitCloneInfo.targetDirectory).checkout([gitCloneInfo.sha]); + await simpleGit(gitCloneInfo.targetDirectory).checkout([gitCloneInfo.ref]); } } diff --git a/packages/shared/src/models/IRecipe.ts b/packages/shared/src/models/IRecipe.ts index c8e6be210..976f90261 100644 --- a/packages/shared/src/models/IRecipe.ts +++ b/packages/shared/src/models/IRecipe.ts @@ -5,8 +5,7 @@ export interface Recipe { description: string; icon?: string; repository: string; - branch: string; - sha: string; + ref: string; readme: string; config?: string; models?: string[];