MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchTree

Function fetchTree

apps/sim/connectors/github/github.ts:82–112  ·  view source on GitHub ↗

* Fetches the full recursive tree for a branch.

(
  accessToken: string,
  owner: string,
  repo: string,
  branch: string
)

Source from the content-addressed store, hash-verified

80 * Fetches the full recursive tree for a branch.
81 */
82async function fetchTree(
83 accessToken: string,
84 owner: string,
85 repo: string,
86 branch: string
87): Promise<TreeItem[]> {
88 const url = `${GITHUB_API_URL}/repos/${owner}/${repo}/git/trees/${encodeURIComponent(branch)}?recursive=1`
89
90 const response = await fetchWithRetry(url, {
91 method: 'GET',
92 headers: {
93 Accept: 'application/vnd.github+json',
94 Authorization: `Bearer ${accessToken}`,
95 'X-GitHub-Api-Version': '2022-11-28',
96 },
97 })
98
99 if (!response.ok) {
100 const errorText = await response.text()
101 logger.error('Failed to fetch GitHub tree', { status: response.status, error: errorText })
102 throw new Error(`Failed to fetch repository tree: ${response.status}`)
103 }
104
105 const data = await response.json()
106
107 if (data.truncated) {
108 logger.warn('GitHub tree was truncated — some files may be missing', { owner, repo, branch })
109 }
110
111 return (data.tree || []).filter((item: TreeItem) => item.type === 'blob')
112}
113
114/**
115 * Fetches blob content via the Git Blobs API. Used as a fallback when the

Callers 1

github.tsFile · 0.85

Calls 4

fetchWithRetryFunction · 0.90
textMethod · 0.80
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected