gitgrip 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +75 -1
  2. package/dist/commands/pr/create.d.ts.map +1 -1
  3. package/dist/commands/pr/create.js +29 -8
  4. package/dist/commands/pr/create.js.map +1 -1
  5. package/dist/commands/pr/merge.d.ts.map +1 -1
  6. package/dist/commands/pr/merge.js +40 -33
  7. package/dist/commands/pr/merge.js.map +1 -1
  8. package/dist/commands/pr/status.d.ts.map +1 -1
  9. package/dist/commands/pr/status.js +15 -11
  10. package/dist/commands/pr/status.js.map +1 -1
  11. package/dist/lib/github.d.ts +28 -4
  12. package/dist/lib/github.d.ts.map +1 -1
  13. package/dist/lib/github.js +65 -126
  14. package/dist/lib/github.js.map +1 -1
  15. package/dist/lib/linker.d.ts +19 -4
  16. package/dist/lib/linker.d.ts.map +1 -1
  17. package/dist/lib/linker.js +107 -16
  18. package/dist/lib/linker.js.map +1 -1
  19. package/dist/lib/manifest.d.ts +12 -1
  20. package/dist/lib/manifest.d.ts.map +1 -1
  21. package/dist/lib/manifest.js +45 -5
  22. package/dist/lib/manifest.js.map +1 -1
  23. package/dist/lib/platform/azure-devops.d.ts +83 -0
  24. package/dist/lib/platform/azure-devops.d.ts.map +1 -0
  25. package/dist/lib/platform/azure-devops.js +378 -0
  26. package/dist/lib/platform/azure-devops.js.map +1 -0
  27. package/dist/lib/platform/github.d.ts +82 -0
  28. package/dist/lib/platform/github.d.ts.map +1 -0
  29. package/dist/lib/platform/github.js +285 -0
  30. package/dist/lib/platform/github.js.map +1 -0
  31. package/dist/lib/platform/gitlab.d.ts +82 -0
  32. package/dist/lib/platform/gitlab.d.ts.map +1 -0
  33. package/dist/lib/platform/gitlab.js +331 -0
  34. package/dist/lib/platform/gitlab.js.map +1 -0
  35. package/dist/lib/platform/index.d.ts +60 -0
  36. package/dist/lib/platform/index.d.ts.map +1 -0
  37. package/dist/lib/platform/index.js +132 -0
  38. package/dist/lib/platform/index.js.map +1 -0
  39. package/dist/lib/platform/types.d.ts +162 -0
  40. package/dist/lib/platform/types.d.ts.map +1 -0
  41. package/dist/lib/platform/types.js +5 -0
  42. package/dist/lib/platform/types.js.map +1 -0
  43. package/dist/types.d.ts +39 -5
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +3 -1
@@ -0,0 +1,82 @@
1
+ import type { HostingPlatform, PlatformType, PlatformConfig, ParsedRepoInfo, PullRequest, PRCreateResult, PRMergeOptions, PRReview, StatusCheckResult } from './types.js';
2
+ /**
3
+ * GitHub platform adapter implementing the HostingPlatform interface
4
+ */
5
+ export declare class GitHubPlatform implements HostingPlatform {
6
+ readonly type: PlatformType;
7
+ private octokit;
8
+ private config;
9
+ constructor(config?: PlatformConfig);
10
+ /**
11
+ * Get GitHub token from environment or gh CLI
12
+ */
13
+ getToken(): Promise<string>;
14
+ /**
15
+ * Get or create Octokit instance
16
+ */
17
+ private getOctokit;
18
+ /**
19
+ * Create a pull request
20
+ */
21
+ createPullRequest(owner: string, repo: string, head: string, base: string, title: string, body?: string, draft?: boolean): Promise<PRCreateResult>;
22
+ /**
23
+ * Get pull request details
24
+ */
25
+ getPullRequest(owner: string, repo: string, pullNumber: number): Promise<PullRequest>;
26
+ /**
27
+ * Update pull request body
28
+ */
29
+ updatePullRequestBody(owner: string, repo: string, pullNumber: number, body: string): Promise<void>;
30
+ /**
31
+ * Merge a pull request
32
+ */
33
+ mergePullRequest(owner: string, repo: string, pullNumber: number, options?: PRMergeOptions): Promise<boolean>;
34
+ /**
35
+ * Find PR by branch name
36
+ */
37
+ findPRByBranch(owner: string, repo: string, branch: string): Promise<PRCreateResult | null>;
38
+ /**
39
+ * Check if PR is approved
40
+ */
41
+ isPullRequestApproved(owner: string, repo: string, pullNumber: number): Promise<boolean>;
42
+ /**
43
+ * Get PR reviews
44
+ */
45
+ getPullRequestReviews(owner: string, repo: string, pullNumber: number): Promise<PRReview[]>;
46
+ /**
47
+ * Get status checks for a commit
48
+ */
49
+ getStatusChecks(owner: string, repo: string, ref: string): Promise<StatusCheckResult>;
50
+ /**
51
+ * Parse GitHub URL to extract owner/repo
52
+ */
53
+ parseRepoUrl(url: string): ParsedRepoInfo | null;
54
+ /**
55
+ * Check if URL matches GitHub
56
+ */
57
+ matchesUrl(url: string): boolean;
58
+ /**
59
+ * Generate HTML comment for linked PR tracking
60
+ */
61
+ generateLinkedPRComment(links: {
62
+ repoName: string;
63
+ number: number;
64
+ }[]): string;
65
+ /**
66
+ * Parse linked PRs from PR body
67
+ */
68
+ parseLinkedPRComment(body: string): {
69
+ repoName: string;
70
+ number: number;
71
+ }[];
72
+ }
73
+ /**
74
+ * Get a GitHub platform instance (cached by config)
75
+ * @deprecated Use getPlatformAdapter('github', config) from platform/index.ts instead
76
+ */
77
+ export declare function getGitHubPlatform(config?: PlatformConfig): GitHubPlatform;
78
+ /**
79
+ * Create a new GitHub platform instance (for custom configurations)
80
+ */
81
+ export declare function createGitHubPlatform(config?: PlatformConfig): GitHubPlatform;
82
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/lib/platform/github.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,cAAc,EACd,QAAQ,EACR,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAY;IAEvC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,CAAC,EAAE,cAAc;IAInC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAqBjC;;OAEG;YACW,UAAU;IAexB;;OAEG;IACG,iBAAiB,CACrB,KAAK,EAAE,MA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C,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,uBAAuB,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,MAAM;IAK9E;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE;CAY3E;AAKD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,CAQzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,CAE5E"}
@@ -0,0 +1,285 @@
1
+ /**
2
+ * GitHub hosting platform adapter
3
+ */
4
+ import { Octokit } from '@octokit/rest';
5
+ import { execSync } from 'child_process';
6
+ /**
7
+ * GitHub platform adapter implementing the HostingPlatform interface
8
+ */
9
+ export class GitHubPlatform {
10
+ type = 'github';
11
+ octokit = null;
12
+ config;
13
+ constructor(config) {
14
+ this.config = config ?? { type: 'github' };
15
+ }
16
+ /**
17
+ * Get GitHub token from environment or gh CLI
18
+ */
19
+ async getToken() {
20
+ // Try environment variable first
21
+ if (process.env.GITHUB_TOKEN) {
22
+ return process.env.GITHUB_TOKEN;
23
+ }
24
+ // Try gh CLI
25
+ try {
26
+ const token = execSync('gh auth token', { encoding: 'utf-8' }).trim();
27
+ if (token) {
28
+ return token;
29
+ }
30
+ }
31
+ catch {
32
+ // gh CLI not available or not authenticated
33
+ }
34
+ throw new Error('GitHub token not found. Set GITHUB_TOKEN environment variable or run "gh auth login"');
35
+ }
36
+ /**
37
+ * Get or create Octokit instance
38
+ */
39
+ async getOctokit() {
40
+ if (!this.octokit) {
41
+ const token = await this.getToken();
42
+ const options = { auth: token };
43
+ // Support GitHub Enterprise
44
+ if (this.config.baseUrl) {
45
+ options.baseUrl = `${this.config.baseUrl}/api/v3`;
46
+ }
47
+ this.octokit = new Octokit(options);
48
+ }
49
+ return this.octokit;
50
+ }
51
+ /**
52
+ * Create a pull request
53
+ */
54
+ async createPullRequest(owner, repo, head, base, title, body = '', draft = false) {
55
+ const octokit = await this.getOctokit();
56
+ const response = await octokit.pulls.create({
57
+ owner,
58
+ repo,
59
+ head,
60
+ base,
61
+ title,
62
+ body,
63
+ draft,
64
+ });
65
+ return {
66
+ number: response.data.number,
67
+ url: response.data.html_url,
68
+ };
69
+ }
70
+ /**
71
+ * Get pull request details
72
+ */
73
+ async getPullRequest(owner, repo, pullNumber) {
74
+ const octokit = await this.getOctokit();
75
+ const response = await octokit.pulls.get({
76
+ owner,
77
+ repo,
78
+ pull_number: pullNumber,
79
+ });
80
+ return {
81
+ number: response.data.number,
82
+ url: response.data.html_url,
83
+ title: response.data.title,
84
+ body: response.data.body ?? '',
85
+ state: response.data.state,
86
+ merged: response.data.merged,
87
+ mergeable: response.data.mergeable,
88
+ head: {
89
+ ref: response.data.head.ref,
90
+ sha: response.data.head.sha,
91
+ },
92
+ base: {
93
+ ref: response.data.base.ref,
94
+ },
95
+ };
96
+ }
97
+ /**
98
+ * Update pull request body
99
+ */
100
+ async updatePullRequestBody(owner, repo, pullNumber, body) {
101
+ const octokit = await this.getOctokit();
102
+ await octokit.pulls.update({
103
+ owner,
104
+ repo,
105
+ pull_number: pullNumber,
106
+ body,
107
+ });
108
+ }
109
+ /**
110
+ * Merge a pull request
111
+ */
112
+ async mergePullRequest(owner, repo, pullNumber, options = {}) {
113
+ const octokit = await this.getOctokit();
114
+ const mergeMethod = options.method ?? 'merge';
115
+ try {
116
+ await octokit.pulls.merge({
117
+ owner,
118
+ repo,
119
+ pull_number: pullNumber,
120
+ merge_method: mergeMethod,
121
+ });
122
+ // Delete branch if requested
123
+ if (options.deleteBranch) {
124
+ const pr = await this.getPullRequest(owner, repo, pullNumber);
125
+ try {
126
+ await octokit.git.deleteRef({
127
+ owner,
128
+ repo,
129
+ ref: `heads/${pr.head.ref}`,
130
+ });
131
+ }
132
+ catch {
133
+ // Branch deletion failure is not critical
134
+ }
135
+ }
136
+ return true;
137
+ }
138
+ catch {
139
+ return false;
140
+ }
141
+ }
142
+ /**
143
+ * Find PR by branch name
144
+ */
145
+ async findPRByBranch(owner, repo, branch) {
146
+ const octokit = await this.getOctokit();
147
+ const response = await octokit.pulls.list({
148
+ owner,
149
+ repo,
150
+ head: `${owner}:${branch}`,
151
+ state: 'open',
152
+ });
153
+ if (response.data.length > 0) {
154
+ return {
155
+ number: response.data[0].number,
156
+ url: response.data[0].html_url,
157
+ };
158
+ }
159
+ return null;
160
+ }
161
+ /**
162
+ * Check if PR is approved
163
+ */
164
+ async isPullRequestApproved(owner, repo, pullNumber) {
165
+ const reviews = await this.getPullRequestReviews(owner, repo, pullNumber);
166
+ // Consider approved if at least one APPROVED review and no CHANGES_REQUESTED
167
+ const hasApproval = reviews.some((r) => r.state === 'APPROVED');
168
+ const hasChangesRequested = reviews.some((r) => r.state === 'CHANGES_REQUESTED');
169
+ return hasApproval && !hasChangesRequested;
170
+ }
171
+ /**
172
+ * Get PR reviews
173
+ */
174
+ async getPullRequestReviews(owner, repo, pullNumber) {
175
+ const octokit = await this.getOctokit();
176
+ const response = await octokit.pulls.listReviews({
177
+ owner,
178
+ repo,
179
+ pull_number: pullNumber,
180
+ });
181
+ return response.data.map((review) => ({
182
+ state: review.state,
183
+ user: review.user?.login ?? 'unknown',
184
+ }));
185
+ }
186
+ /**
187
+ * Get status checks for a commit
188
+ */
189
+ async getStatusChecks(owner, repo, ref) {
190
+ const octokit = await this.getOctokit();
191
+ const response = await octokit.repos.getCombinedStatusForRef({
192
+ owner,
193
+ repo,
194
+ ref,
195
+ });
196
+ return {
197
+ state: response.data.state,
198
+ statuses: response.data.statuses.map((s) => ({
199
+ context: s.context,
200
+ state: s.state,
201
+ })),
202
+ };
203
+ }
204
+ /**
205
+ * Parse GitHub URL to extract owner/repo
206
+ */
207
+ parseRepoUrl(url) {
208
+ // SSH format: git@github.com:owner/repo.git
209
+ const sshMatch = url.match(/git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
210
+ if (sshMatch) {
211
+ return { owner: sshMatch[1], repo: sshMatch[2] };
212
+ }
213
+ // HTTPS format: https://github.com/owner/repo.git
214
+ const httpsMatch = url.match(/https?:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/);
215
+ if (httpsMatch) {
216
+ return { owner: httpsMatch[1], repo: httpsMatch[2] };
217
+ }
218
+ // GitHub Enterprise SSH: git@github.company.com:owner/repo.git
219
+ if (this.config.baseUrl) {
220
+ const host = new URL(this.config.baseUrl).host;
221
+ const escapedHost = host.replace(/\./g, '\\.');
222
+ const enterpriseSshRegex = new RegExp(`git@${escapedHost}:([^/]+)/(.+?)(?:\\.git)?$`);
223
+ const enterpriseSshMatch = url.match(enterpriseSshRegex);
224
+ if (enterpriseSshMatch) {
225
+ return { owner: enterpriseSshMatch[1], repo: enterpriseSshMatch[2] };
226
+ }
227
+ // GitHub Enterprise HTTPS
228
+ const enterpriseHttpsRegex = new RegExp(`https?://${escapedHost}/([^/]+)/(.+?)(?:\\.git)?$`);
229
+ const enterpriseHttpsMatch = url.match(enterpriseHttpsRegex);
230
+ if (enterpriseHttpsMatch) {
231
+ return { owner: enterpriseHttpsMatch[1], repo: enterpriseHttpsMatch[2] };
232
+ }
233
+ }
234
+ return null;
235
+ }
236
+ /**
237
+ * Check if URL matches GitHub
238
+ */
239
+ matchesUrl(url) {
240
+ return this.parseRepoUrl(url) !== null;
241
+ }
242
+ /**
243
+ * Generate HTML comment for linked PR tracking
244
+ */
245
+ generateLinkedPRComment(links) {
246
+ const prLinks = links.map((pr) => `${pr.repoName}#${pr.number}`).join(',');
247
+ return `<!-- codi-repo:links:${prLinks} -->`;
248
+ }
249
+ /**
250
+ * Parse linked PRs from PR body
251
+ */
252
+ parseLinkedPRComment(body) {
253
+ const match = body.match(/<!-- codi-repo:links:(.+?) -->/);
254
+ if (!match) {
255
+ return [];
256
+ }
257
+ const links = match[1].split(',');
258
+ return links.map((link) => {
259
+ const [repoName, numStr] = link.split('#');
260
+ return { repoName, number: parseInt(numStr, 10) };
261
+ });
262
+ }
263
+ }
264
+ // Default instance cache (keyed by baseUrl for proper config handling)
265
+ const instanceCache = new Map();
266
+ /**
267
+ * Get a GitHub platform instance (cached by config)
268
+ * @deprecated Use getPlatformAdapter('github', config) from platform/index.ts instead
269
+ */
270
+ export function getGitHubPlatform(config) {
271
+ const cacheKey = config?.baseUrl ?? 'default';
272
+ let instance = instanceCache.get(cacheKey);
273
+ if (!instance) {
274
+ instance = new GitHubPlatform(config);
275
+ instanceCache.set(cacheKey, instance);
276
+ }
277
+ return instance;
278
+ }
279
+ /**
280
+ * Create a new GitHub platform instance (for custom configurations)
281
+ */
282
+ export function createGitHubPlatform(config) {
283
+ return new GitHubPlatform(config);
284
+ }
285
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/lib/platform/github.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAazC;;GAEG;AACH,MAAM,OAAO,cAAc;IAChB,IAAI,GAAiB,QAAQ,CAAC;IAE/B,OAAO,GAAmB,IAAI,CAAC;IAC/B,MAAM,CAAiB;IAE/B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,iCAAiC;QACjC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QAClC,CAAC;QAED,aAAa;QACb,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,QAAQ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C;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACxB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,aAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACvD,MAAM,QAAQ,GAAG,MAAM,EAAE,OAAO,IAAI,SAAS,CAAC;IAC9C,IAAI,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACtC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { HostingPlatform, PlatformType, PlatformConfig, ParsedRepoInfo, PullRequest, PRCreateResult, PRMergeOptions, PRReview, StatusCheckResult } from './types.js';
2
+ /**
3
+ * GitLab platform adapter implementing the HostingPlatform interface
4
+ */
5
+ export declare class GitLabPlatform implements HostingPlatform {
6
+ readonly type: PlatformType;
7
+ private token;
8
+ private config;
9
+ private baseUrl;
10
+ constructor(config?: PlatformConfig);
11
+ /**
12
+ * Get GitLab token from environment or glab CLI
13
+ */
14
+ getToken(): Promise<string>;
15
+ /**
16
+ * Make authenticated API request to GitLab
17
+ */
18
+ private apiRequest;
19
+ /**
20
+ * Encode project path for GitLab API (owner/repo -> owner%2Frepo)
21
+ */
22
+ private encodeProject;
23
+ /**
24
+ * Create a merge request
25
+ */
26
+ createPullRequest(owner: string, repo: string, head: string, base: string, title: string, body?: string, draft?: boolean): Promise<PRCreateResult>;
27
+ /**
28
+ * Get merge request details
29
+ */
30
+ getPullRequest(owner: string, repo: string, pullNumber: number): Promise<PullRequest>;
31
+ /**
32
+ * Update merge request description
33
+ */
34
+ updatePullRequestBody(owner: string, repo: string, pullNumber: number, body: string): Promise<void>;
35
+ /**
36
+ * Merge a merge request
37
+ */
38
+ mergePullRequest(owner: string, repo: string, pullNumber: number, options?: PRMergeOptions): Promise<boolean>;
39
+ /**
40
+ * Find MR by branch name
41
+ */
42
+ findPRByBranch(owner: string, repo: string, branch: string): Promise<PRCreateResult | null>;
43
+ /**
44
+ * Check if MR is approved
45
+ */
46
+ isPullRequestApproved(owner: string, repo: string, pullNumber: number): Promise<boolean>;
47
+ /**
48
+ * Get MR reviews/approvals
49
+ */
50
+ getPullRequestReviews(owner: string, repo: string, pullNumber: number): Promise<PRReview[]>;
51
+ /**
52
+ * Get pipeline status for MR
53
+ */
54
+ getStatusChecks(owner: string, repo: string, ref: string): Promise<StatusCheckResult>;
55
+ /**
56
+ * Parse GitLab URL to extract owner/repo (group/project)
57
+ */
58
+ parseRepoUrl(url: string): ParsedRepoInfo | null;
59
+ /**
60
+ * Check if URL matches GitLab
61
+ */
62
+ matchesUrl(url: string): boolean;
63
+ /**
64
+ * Generate HTML comment for linked MR tracking
65
+ */
66
+ generateLinkedPRComment(links: {
67
+ repoName: string;
68
+ number: number;
69
+ }[]): string;
70
+ /**
71
+ * Parse linked MRs from MR description
72
+ */
73
+ parseLinkedPRComment(body: string): {
74
+ repoName: string;
75
+ number: number;
76
+ }[];
77
+ }
78
+ /**
79
+ * Create a new GitLab platform instance
80
+ */
81
+ export declare function createGitLabPlatform(config?: PlatformConfig): GitLabPlatform;
82
+ //# sourceMappingURL=gitlab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlab.d.ts","sourceRoot":"","sources":["../../../src/lib/platform/gitlab.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,cAAc,EACd,QAAQ,EACR,iBAAiB,EAClB,MAAM,YAAY,CAAC;AA0BpB;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAY;IAEvC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,cAAc;IAKnC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IA6BjC;;OAEG;YACW,UAAU;IA8BxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACG,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,SAAK,EACT,KAAK,UAAQ,GACZ,OAAO,CAAC,cAAc,CAAC;IAqB1B;;OAEG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC;IAwCvB;;OAEG;IACG,qBAAqB,CACzB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAShB;;OAEG;IACG,gBAAgB,CACpB,KAAK,E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