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

Method getCode

src/scm/gitlab.js:119–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 }
118
119 getCode() {
120 return new Promise((resolve, reject) => {
121 return $.getJSON(
122 `${this.baseUrl}/projects/${getRepo().id}/repository/tree?ref=${getBranch()}&recursive=true&${this.tokenParam}`, {}
123 )
124 .then(resolve)
125 .fail(reject)
126 })
127 .then(response => {
128 const config = getConfig();
129 const re = new RegExp(`(\\${config.filetype}|\\.html${config.manifestEnabled ? '|^appsscript.json' : ''})$`);
130 const promises = response.filter((tree) => {
131 return tree.type === 'blob' && re.test(tree.path);
132 })
133 .map(tree => {
134 return new Promise((resolve, reject) => {
135 $.getJSON(`${this.baseUrl}/projects/${getRepo().id}/repository/files/${encodeURIComponent(tree.path)}?ref=${getBranch()}&${this.tokenParam}`, {})
136 .then((content) => {
137 resolve({
138 file: tree.path,
139 content: decodeURIComponent(escape(atob(content.content)))
140 });
141 })
142 .fail(reject)
143 });
144 });
145 return Promise.all(promises);
146 })
147 .then(code => {
148 return code.reduce((hash, elem) => {
149 if (elem) {
150 hash[elem.file] = elem.content;
151 }
152 return hash;
153 }, {})
154 })
155 }
156
157 getNamespaces() {
158 return getAllItems(Promise.resolve({

Callers 1

prepareCodeFunction · 0.45

Calls 4

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

Tested by

no test coverage detected