MCPcopy Index your code
hub / github.com/massCodeIO/massCode / parseGitHubGistResponse

Function parseGitHubGistResponse

src/main/import/snippets/githubGists.ts:99–173  ·  view source on GitHub ↗
(
  gist: GitHubGistResponse,
  source: string,
)

Source from the content-addressed store, hash-verified

97}
98
99export function parseGitHubGistResponse(
100 gist: GitHubGistResponse,
101 source: string,
102): SnippetImportParseResult {
103 const files = getGistFiles(gist)
104 const warnings: SnippetImportParseResult['warnings'] = []
105
106 if (!files.length) {
107 return {
108 snippets: [],
109 warnings: [
110 {
111 code: 'gist.noFiles',
112 source,
113 },
114 ],
115 }
116 }
117
118 const contents: SnippetImportCandidate['contents'] = []
119
120 files.forEach((file) => {
121 const filename
122 = typeof file.filename === 'string' && file.filename.trim()
123 ? file.filename
124 : 'gist-file'
125
126 if (file.truncated) {
127 warnings.push({
128 code: 'gist.truncatedSkipped',
129 source: `${source}/${filename}`,
130 })
131 return
132 }
133
134 if (typeof file.content !== 'string') {
135 warnings.push({
136 code: 'gist.contentMissing',
137 source: `${source}/${filename}`,
138 })
139 return
140 }
141
142 contents.push({
143 label: normalizeImportEntryName(filename, 'Fragment'),
144 language: getLanguage(file),
145 value: file.content,
146 })
147 })
148
149 if (!contents.length) {
150 return {
151 snippets: [],
152 warnings,
153 }
154 }
155
156 return {

Callers 2

parsers.test.tsFile · 0.90
fetchGitHubGistImportFunction · 0.85

Calls 4

normalizeImportEntryNameFunction · 0.90
getGistFilesFunction · 0.85
getLanguageFunction · 0.85
getSnippetNameFunction · 0.85

Tested by

no test coverage detected