( step: CodeTourStep, workspaceRoot?: Uri, ref?: string )
| 67 | } |
| 68 | |
| 69 | export async function getStepFileUri( |
| 70 | step: CodeTourStep, |
| 71 | workspaceRoot?: Uri, |
| 72 | ref?: string |
| 73 | ): Promise<Uri> { |
| 74 | let uri; |
| 75 | if (step.contents) { |
| 76 | uri = Uri.parse(`${FS_SCHEME}://current/${step.file}`); |
| 77 | } else if (step.uri || step.file) { |
| 78 | uri = step.uri |
| 79 | ? Uri.parse(step.uri) |
| 80 | : getFileUri(step.file!, workspaceRoot); |
| 81 | |
| 82 | if (api && ref && ref !== "HEAD") { |
| 83 | const repo = api.getRepository(uri); |
| 84 | |
| 85 | if ( |
| 86 | repo && |
| 87 | repo.state.HEAD && |
| 88 | repo.state.HEAD.name !== ref && // The tour refs the user's current branch |
| 89 | repo.state.HEAD.commit !== ref && // The tour refs the user's HEAD commit |
| 90 | repo.state.HEAD.commit !== // The tour refs a branch/tag that points at the user's HEAD commit |
| 91 | repo.state.refs.find(gitRef => gitRef.name === ref)?.commit |
| 92 | ) { |
| 93 | uri = await api.toGitUri(uri, ref); |
| 94 | } |
| 95 | } |
| 96 | } else { |
| 97 | uri = CONTENT_URI; |
| 98 | } |
| 99 | |
| 100 | return uri; |
| 101 | } |
| 102 | |
| 103 | export function getActiveWorkspacePath() { |
| 104 | return store.activeTour!.workspaceRoot?.path || ""; |
no test coverage detected