generated from bywhitebird/starter-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41d6672
commit 789d151
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/octent/src/lib/utils/content-explorer/functions/create-reset.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type LightningFS from '@isomorphic-git/lightning-fs' | ||
import * as git from 'isomorphic-git' | ||
|
||
import type { GitRepoOptions } from '../content-explorer' | ||
|
||
/** | ||
* @param parameters The parameters to pass to the function | ||
* @param parameters.fs The file system to use | ||
* @param parameters.gitRepoOptions The options to pass to git | ||
* @returns A function that pulls the repository | ||
*/ | ||
export function createReset(parameters: { | ||
fs: LightningFS.PromisifiedFS, | ||
gitRepoOptions: Readonly<GitRepoOptions> | ||
}) { | ||
// eslint-disable-next-line functional/functional-parameters | ||
return async function reset() { | ||
const branch = await git.currentBranch(parameters.gitRepoOptions) | ||
|
||
if (branch === undefined) { | ||
return | ||
} | ||
|
||
await parameters.fs.unlink( | ||
`${parameters.gitRepoOptions.dir}/.git/refs/heads/${branch}`, | ||
) | ||
|
||
await git.checkout({ | ||
...parameters.gitRepoOptions, | ||
ref: branch, | ||
force: true, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters