From 42c389b9133af1001dfeb09ba776c0985595b45b Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 24 Feb 2021 10:45:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(repos):=20=E6=97=A0=E6=B3=95=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=9C=E7=A8=8B=E7=89=88=E6=9C=AC=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +-- config.yml | 13 ------------- src/repos/repos.service.spec.ts | 15 ++++++++++----- src/repos/repos.service.ts | 9 +-------- 4 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 config.yml diff --git a/.gitignore b/.gitignore index 51fa54f..a13915f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,5 +33,4 @@ lerna-debug.log* !.vscode/launch.json !.vscode/extensions.json -workspaces/* -!workspaces/.gitkeep \ No newline at end of file +/config.yml \ No newline at end of file diff --git a/config.yml b/config.yml deleted file mode 100644 index fbb3e40..0000000 --- a/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -env: dev -http: - port: 7122 - -db: - postgres: - host: 192.168.31.194 - port: 5432 - database: fennec - username: fennec - password: -workspaces: - root: 'E:\Projects\demos\workspaces' \ No newline at end of file diff --git a/src/repos/repos.service.spec.ts b/src/repos/repos.service.spec.ts index 1170ef2..1907379 100644 --- a/src/repos/repos.service.spec.ts +++ b/src/repos/repos.service.spec.ts @@ -3,10 +3,10 @@ import { getRepositoryToken } from '@nestjs/typeorm'; import { Project } from '../projects/project.entity'; import { ReposService } from './repos.service'; import { ConfigService } from '@nestjs/config'; -import { rm, unlink } from 'fs/promises'; +import { rm } from 'fs/promises'; import { join } from 'path'; -const workspacesRoot = '/Users/ivanli/Projects/fennec/workspaces'; +const workspacesRoot = 'E:\\Projects\\demos\\workspaces'; describe('ReposService', () => { let service: ReposService; @@ -21,7 +21,15 @@ describe('ReposService', () => { }), ), })); + afterEach(async () => { + await rm(join(workspacesRoot, 'test1'), { + recursive: true, + }).catch(() => undefined); + }); beforeEach(async () => { + await rm(join(workspacesRoot, 'test1'), { + recursive: true, + }).catch(() => undefined); const module: TestingModule = await Test.createTestingModule({ providers: [ ReposService, @@ -47,9 +55,6 @@ describe('ReposService', () => { expect(service).toBeDefined(); }); describe('listLogs', () => { - beforeEach(async () => { - await rm(join(workspacesRoot, 'test1'), { recursive: true }); - }); it('should be return logs', async () => { const result = await service.listLogs({ projectId: '1' }); expect(result).toBeDefined(); diff --git a/src/repos/repos.service.ts b/src/repos/repos.service.ts index b0062dc..b14a142 100644 --- a/src/repos/repos.service.ts +++ b/src/repos/repos.service.ts @@ -34,7 +34,6 @@ export class ReposService { if (firstInit) { await git.init(); await git.addRemote('origin', project.sshUrl); - // await git.clone(project.sshUrl, workspacePath); } return git; } @@ -44,13 +43,7 @@ export class ReposService { id: dto.projectId, }); const git = await this.getGit(project); - await git - .outputHandler((command, stdout, stderr) => { - stdout.pipe(process.stdout); - stderr.pipe(process.stderr); - }) - .fetch(); - // await git.checkoutBranch('master', 'origin/master'); + await git.fetch(); return await git.log({ '--branches': dto.branch ?? '', '--remotes': 'origin',