Skip to content

Commit

Permalink
fix: use single ref field
Browse files Browse the repository at this point in the history
Signed-off-by: lstocchi <[email protected]>
  • Loading branch information
lstocchi committed Jan 30, 2024
1 parent f4d1711 commit 6866c8d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
6 changes: 2 additions & 4 deletions packages/backend/src/ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
21 changes: 7 additions & 14 deletions packages/backend/src/managers/applicationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ describe('pullApplication', () => {
name: 'Recipe 1',
categories: [],
description: '',
branch: 'branch',
sha: '000000',
ref: '000000',
readme: '',
repository: 'repo',
};
Expand All @@ -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') {
Expand All @@ -211,8 +209,7 @@ describe('pullApplication', () => {
name: 'Recipe 1',
categories: [],
description: '',
branch: 'branch',
sha: '000000',
ref: '000000',
readme: '',
repository: 'repo',
};
Expand All @@ -239,8 +236,7 @@ describe('pullApplication', () => {
id: 'recipe1',
name: 'Recipe 1',
categories: [],
branch: 'branch',
sha: '000000',
ref: '000000',
description: '',
readme: '',
repository: 'repo',
Expand Down Expand Up @@ -270,8 +266,7 @@ describe('pullApplication', () => {
name: 'Recipe 1',
categories: [],
description: '',
branch: 'branch',
sha: '000000',
ref: '000000',
readme: '',
repository: 'repo',
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -348,8 +342,7 @@ describe('doCheckout', () => {
await manager.doCheckout(
{
repository: 'repo',
branch: 'branch',
sha: '000000',
ref: '000000',
targetDirectory: 'folder',
},
taskUtils,
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/managers/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions packages/backend/src/managers/gitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
3 changes: 1 addition & 2 deletions packages/shared/src/models/IRecipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit 6866c8d

Please sign in to comment.