MCPcopy
hub / github.com/opentrace/opentrace / indexRepo

Method indexRepo

plugins/opencode/src/graph-client.ts:757–786  ·  view source on GitHub ↗

* `ok` reflects the CLI's exit status (only exit 0 is success). On failure, * `message` is the curated/CLI text, suitable to surface verbatim. * `inProgress` flags EXIT_INDEX_IN_PROGRESS as retryable rather * than a hard error.

(
    pathOrUrl: string,
    repoId?: string,
    opts?: { token?: string; ref?: string },
  )

Source from the content-addressed store, hash-verified

755 * than a hard error.
756 */
757 async indexRepo(
758 pathOrUrl: string,
759 repoId?: string,
760 opts?: { token?: string; ref?: string },
761 ): Promise<{ ok: boolean; message: string; inProgress?: boolean }> {
762 // Standard git remote schemes plus the SCP-like `git@host:org/repo` form.
763 const isUrl =
764 /^(?:https?|git\+ssh|ssh|git):\/\//.test(pathOrUrl) ||
765 /^git@/.test(pathOrUrl)
766
767 const args: string[] = isUrl ? ["fetch-and-index", pathOrUrl] : ["index", pathOrUrl]
768 if (repoId) args.push("--repo-id", repoId)
769 if (isUrl) {
770 if (opts?.token) args.push("--token", opts.token)
771 if (opts?.ref) args.push("--ref", opts.ref)
772 }
773
774 const result = await this.runWithTimeout(args, this.indexTimeout)
775 if (result.ok) {
776 return {
777 ok: true,
778 message: result.output || (isUrl ? "Fetch-and-index completed" : "Indexing completed"),
779 }
780 }
781 return {
782 ok: false,
783 message: result.output || (isUrl ? "Fetch-and-index failed or no output" : "Indexing failed or no output"),
784 inProgress: result.exitCode === EXIT_INDEX_IN_PROGRESS,
785 }
786 }
787
788 /**
789 * `ok` is true only on CLI exit 0. `output` is the text to surface

Callers 2

executeFunction · 0.80

Calls 2

runWithTimeoutMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected