Commit 52ef221d authored by nanahira's avatar nanahira

add reset for existing checkout

parent 06b93152
Pipeline #5223 passed with stages
in 38 minutes and 16 seconds
import { Connection, Repository } from 'typeorm'; import { Connection, Repository } from 'typeorm';
import { InjectConnection } from '@nestjs/typeorm'; import { InjectConnection } from '@nestjs/typeorm';
import { ConsoleLogger, Injectable } from '@nestjs/common'; import { ConsoleLogger, Injectable } from '@nestjs/common';
import simpleGit, { SimpleGit } from 'simple-git'; import simpleGit, { ResetMode, SimpleGit } from 'simple-git';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import path from 'path'; import path from 'path';
import { File } from './entities/File.entity'; import { File } from './entities/File.entity';
...@@ -178,6 +178,9 @@ export class AppService extends ConsoleLogger { ...@@ -178,6 +178,9 @@ export class AppService extends ConsoleLogger {
await this.git.fetch('origin', branchName); await this.git.fetch('origin', branchName);
} }
await this.git.checkout(branchName, ['-f']); await this.git.checkout(branchName, ['-f']);
if (fetch) {
await this.git.reset(ResetMode.HARD, [`origin/${branchName}`]);
}
this.log(`Checked out existing branch ${branchName}`); this.log(`Checked out existing branch ${branchName}`);
} catch (e) { } catch (e) {
this.error( this.error(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment