Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
})
if (errors && errors.length > 0) {
throw new Error(`GraphQL response error: ${errors[0].message}`)
}
const canonicalURLs: string[] = data.comby.results.map(
(r: any) => `git://${r.file.commit.repository.name}?${r.file.commit.oid}#${r.file.path}`
)
const docs = await Promise.all(canonicalURLs.map(url => sourcegraph.workspace.openTextDocument(new URL(url))))
const edit = new sourcegraph.WorkspaceEdit()
for (const [i, doc] of docs.entries()) {
if (doc.text!.length > 15000) {
continue // TODO!(sqs): skip too large
}
edit.set(new URL(doc.uri), [sourcegraph.TextEdit.patch(data.comby.results[i].rawDiff)])
}
return (edit as any).toJSON()
}
map(result => {
const edit = new sourcegraph.WorkspaceEdit()
for (const file of files) {
const name = path.basename(parseRepoURI(file.uri).filePath!)
const patch = result.fileDiffs![name]
if (patch) {
edit.set(new URL(file.uri), [sourcegraph.TextEdit.patch(patch)])
}
}
return edit
})
)
map(result => {
const edit = new sourcegraph.WorkspaceEdit()
for (const file of files) {
const name = path.basename(parseRepoURI(file.uri).filePath!)
edit.set(new URL(file.uri), [sourcegraph.TextEdit.patch(result.fileDiffs![name])])
}
return edit
})
)