MCPcopy
hub / github.com/QasimWani/LeetHub / uploadGit

Function uploadGit

scripts/leetcode.js:181–254  ·  view source on GitHub ↗
(
  code,
  problemName,
  fileName,
  msg,
  action,
  prepend = true,
  cb = undefined,
  _diff = undefined,
)

Source from the content-addressed store, hash-verified

179};
180
181function uploadGit(
182 code,
183 problemName,
184 fileName,
185 msg,
186 action,
187 prepend = true,
188 cb = undefined,
189 _diff = undefined,
190) {
191 // Assign difficulty
192 if (_diff && _diff !== undefined) {
193 difficulty = _diff.trim();
194 }
195
196 /* Get necessary payload data */
197 chrome.storage.local.get('leethub_token', (t) => {
198 const token = t.leethub_token;
199 if (token) {
200 chrome.storage.local.get('mode_type', (m) => {
201 const mode = m.mode_type;
202 if (mode === 'commit') {
203 /* Get hook */
204 chrome.storage.local.get('leethub_hook', (h) => {
205 const hook = h.leethub_hook;
206 if (hook) {
207 /* Get SHA, if it exists */
208
209 /* to get unique key */
210 const filePath = problemName + fileName;
211 chrome.storage.local.get('stats', (s) => {
212 const { stats } = s;
213 let sha = null;
214
215 if (
216 stats !== undefined &&
217 stats.sha !== undefined &&
218 stats.sha[filePath] !== undefined
219 ) {
220 sha = stats.sha[filePath];
221 }
222
223 if (action === 'upload') {
224 /* Upload to git. */
225 upload(
226 token,
227 hook,
228 code,
229 problemName,
230 fileName,
231 sha,
232 msg,
233 cb,
234 );
235 } else if (action === 'update') {
236 /* Update on git */
237 update(
238 token,

Callers 3

gfg.jsFile · 0.85
findCodeFunction · 0.85
leetcode.jsFile · 0.85

Calls 2

uploadFunction · 0.85
updateFunction · 0.85

Tested by

no test coverage detected