| 13 | |
| 14 | // reset to the start of the last test |
| 15 | const onRunReset = async (action: ResetAction, context: Context): Promise<void> => { |
| 16 | // reset to timeline |
| 17 | const tutorial: TT.Tutorial | null = context.tutorial.get() |
| 18 | const position: T.Position = action.position ? action.position : context.position.get() |
| 19 | |
| 20 | // get last pass commit |
| 21 | const hash: string = getCommitHashByPosition(position, tutorial) |
| 22 | |
| 23 | const branch = tutorial?.config.repo.branch |
| 24 | |
| 25 | if (!branch) { |
| 26 | logger('Error: No repo branch found for tutorial') |
| 27 | return |
| 28 | } |
| 29 | |
| 30 | // load timeline until last pass commit |
| 31 | await reset({ branch, hash }) |
| 32 | |
| 33 | // if tutorial.config.reset.command, run it |
| 34 | const resetActions = tutorial?.config?.reset |
| 35 | if (resetActions) { |
| 36 | await hooks.onReset( |
| 37 | { commands: resetActions?.commands, vscodeCommands: resetActions?.vscodeCommands }, |
| 38 | tutorial?.id as string, |
| 39 | ) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | export default onRunReset |