MCPcopy Index your code
hub / github.com/microsoft/codetour / getStepFileUri

Function getStepFileUri

src/utils.ts:69–101  ·  view source on GitHub ↗
(
  step: CodeTourStep,
  workspaceRoot?: Uri,
  ref?: string
)

Source from the content-addressed store, hash-verified

67}
68
69export 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
103export function getActiveWorkspacePath() {
104 return store.activeTour!.workspaceRoot?.path || "";

Callers 5

deserializeNotebookMethod · 0.90
exportTourFunction · 0.90
renderCurrentStepFunction · 0.90
getTourStepsFunction · 0.90
updateMarkerTitleForStepFunction · 0.85

Calls 3

getFileUriFunction · 0.85
getRepositoryMethod · 0.80
toGitUriMethod · 0.80

Tested by

no test coverage detected