MCPcopy
hub / github.com/iterative/cml / repoBase

Method repoBase

src/drivers/gitlab.js:41–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39 }
40
41 async repoBase() {
42 if (this.detectedBase) return this.detectedBase;
43
44 const { origin, pathname } = new URL(this.repo);
45 const possibleBases = await Promise.all(
46 pathname
47 .split('/')
48 .filter(Boolean)
49 .map(async (_, index, array) => {
50 const components = [origin, ...array.slice(0, index)];
51 const path = components.join('/');
52 try {
53 if (
54 (await this.request({ url: `${path}/api/${API_VER}/version` }))
55 .version
56 )
57 return path;
58 } catch (error) {
59 return error;
60 }
61 })
62 );
63
64 this.detectedBase = possibleBases.find((base) => typeof base === 'string');
65 if (!this.detectedBase) {
66 if (possibleBases.length) throw possibleBases[0];
67 throw new Error('Invalid repository address');
68 }
69
70 return this.detectedBase;
71 }
72
73 async commitCommentCreate(opts = {}) {
74 const { commitSha, report } = opts;

Callers 2

projectPathMethod · 0.95
requestMethod · 0.95

Calls 1

requestMethod · 0.95

Tested by

no test coverage detected