MCPcopy
hub / github.com/leonhartX/gas-github / getRepoCode

Method getRepoCode

src/scm/github.js:231–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229 }
230
231 getRepoCode() {
232 return new Promise((resolve, reject) => {
233 getGitHubJSON(
234 `${this.baseUrl}/repos/${getRepo().fullName}/branches/${getBranch()}`,
235 this.accessToken)
236 .then(resolve)
237 .fail(reject);
238 })
239 .then(response => {
240 return getGitHubJSON(
241 `${this.baseUrl}/repos/${getRepo().fullName}/git/trees/${response.commit.commit.tree.sha}`,
242 this.accessToken, {
243 recursive: 1
244 }
245 );
246 })
247 .then(response => {
248 const config = getConfig();
249 const re = new RegExp(`(\\${config.filetype}|\\.html${config.manifestEnabled ? '|^appsscript.json' : ''})$`);
250 const promises = response.tree.filter((tree) => {
251 return tree.type === 'blob' && re.test(tree.path);
252 })
253 .map(tree => {
254 return new Promise((resolve, reject) => {
255 getGitHubJSON(`${tree.url}?ts=${new Date().getTime()}`, this.accessToken)
256 .then((content) => {
257 resolve({
258 file: tree.path,
259 content: decodeURIComponent(escape(atob(content.content)))
260 });
261 })
262 .fail(reject)
263 });
264 });
265 return Promise.all(promises);
266 });
267 }
268
269 getGistCode() {
270 return new Promise((resolve, reject) => {

Callers 1

getCodeMethod · 0.95

Calls 5

getGitHubJSONFunction · 0.85
getRepoFunction · 0.85
getBranchFunction · 0.85
getConfigFunction · 0.85
escapeFunction · 0.85

Tested by

no test coverage detected