Skip to content

Commit

Permalink
fix: reset git repo before checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Nov 6, 2022
1 parent 6e8d85d commit 646192a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/Leon.ts
Expand Up @@ -3,7 +3,7 @@ import os from 'node:os'
import crypto from 'node:crypto'

import ora from 'ora'
import simpleGit from 'simple-git'
import simpleGit, { CheckRepoActions } from 'simple-git'
import { readPackage } from 'read-pkg'

import { isExistingPath } from '../utils/isExistingPath.js'
Expand Down Expand Up @@ -49,13 +49,13 @@ export class Leon implements LeonOptions {
}

public async manageGit(): Promise<void> {
const dotGitPath = path.join(this.birthPath, '.git')
if (!(await isExistingPath(dotGitPath))) {
const git = simpleGit({ baseDir: this.birthPath })
if (!(await git.checkIsRepo(CheckRepoActions.IS_REPO_ROOT))) {
throw new LogError({
message: `Leon source code is not a git repository.`
})
}
const git = simpleGit({ baseDir: this.birthPath })
await git.reset(['--hard'])
if (this.useDevelopGitBranch) {
await git.checkout('develop')
} else if (this.version != null) {
Expand Down

0 comments on commit 646192a

Please sign in to comment.