@andrebuzeli/git-mcp 2.28.1 → 2.28.2
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.
- package/dist/client.d.ts +306 -306
- package/dist/client.js +298 -298
- package/dist/config.d.ts +310 -310
- package/dist/config.js +392 -392
- package/dist/index.d.ts +22 -22
- package/dist/index.js +89 -89
- package/dist/providers/base-provider.d.ts +160 -160
- package/dist/providers/base-provider.js +274 -274
- package/dist/providers/error-handler.d.ts +50 -50
- package/dist/providers/error-handler.js +175 -175
- package/dist/providers/gitea-provider.d.ts +97 -97
- package/dist/providers/gitea-provider.d.ts.map +1 -1
- package/dist/providers/gitea-provider.js +1015 -1001
- package/dist/providers/gitea-provider.js.map +1 -1
- package/dist/providers/github-provider.d.ts +104 -104
- package/dist/providers/github-provider.d.ts.map +1 -1
- package/dist/providers/github-provider.js +1248 -1234
- package/dist/providers/github-provider.js.map +1 -1
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.js +40 -40
- package/dist/providers/provider-factory.d.ts +74 -74
- package/dist/providers/provider-factory.d.ts.map +1 -1
- package/dist/providers/provider-factory.js +318 -311
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/providers/types.d.ts +318 -318
- package/dist/providers/types.js +6 -6
- package/dist/server.d.ts +76 -76
- package/dist/server.js +306 -306
- package/dist/tools/git-archive.d.ts +165 -165
- package/dist/tools/git-archive.js +233 -233
- package/dist/tools/git-branches.d.ts +430 -430
- package/dist/tools/git-branches.js +627 -627
- package/dist/tools/git-commits.d.ts +485 -485
- package/dist/tools/git-commits.js +735 -735
- package/dist/tools/git-commits.js.map +1 -1
- package/dist/tools/git-config.d.ts +140 -140
- package/dist/tools/git-config.js +268 -268
- package/dist/tools/git-files.d.ts +486 -486
- package/dist/tools/git-files.js +607 -607
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-issues.d.ts +574 -571
- package/dist/tools/git-issues.d.ts.map +1 -1
- package/dist/tools/git-issues.js +741 -740
- package/dist/tools/git-issues.js.map +1 -1
- package/dist/tools/git-pulls.d.ts +697 -694
- package/dist/tools/git-pulls.d.ts.map +1 -1
- package/dist/tools/git-pulls.js +733 -732
- package/dist/tools/git-pulls.js.map +1 -1
- package/dist/tools/git-releases.d.ts +490 -487
- package/dist/tools/git-releases.d.ts.map +1 -1
- package/dist/tools/git-releases.js +558 -557
- package/dist/tools/git-releases.js.map +1 -1
- package/dist/tools/git-remote.d.ts +138 -138
- package/dist/tools/git-remote.js +274 -274
- package/dist/tools/git-repositories.d.ts +483 -483
- package/dist/tools/git-repositories.js +640 -640
- package/dist/tools/git-repositories.js.map +1 -1
- package/dist/tools/git-reset.d.ts +130 -130
- package/dist/tools/git-reset.js +223 -223
- package/dist/tools/git-revert.d.ts +149 -149
- package/dist/tools/git-revert.js +198 -198
- package/dist/tools/git-stash.d.ts +140 -140
- package/dist/tools/git-stash.js +269 -269
- package/dist/tools/git-sync.d.ts +178 -178
- package/dist/tools/git-sync.js +312 -312
- package/dist/tools/git-tags.d.ts +414 -411
- package/dist/tools/git-tags.d.ts.map +1 -1
- package/dist/tools/git-tags.js +486 -485
- package/dist/tools/git-tags.js.map +1 -1
- package/dist/tools/git-webhooks.d.ts +473 -470
- package/dist/tools/git-webhooks.d.ts.map +1 -1
- package/dist/tools/git-webhooks.js +544 -543
- package/dist/tools/git-webhooks.js.map +1 -1
- package/dist/utils/terminal-controller.d.ts +80 -80
- package/dist/utils/terminal-controller.js +345 -345
- package/dist/utils/user-detection.d.ts +24 -24
- package/dist/utils/user-detection.js +53 -53
- package/package.json +2 -2
- package/dist/tools/gh-actions.d.ts +0 -253
- package/dist/tools/gh-actions.d.ts.map +0 -1
- package/dist/tools/gh-actions.js +0 -390
- package/dist/tools/gh-actions.js.map +0 -1
- package/dist/tools/gh-analytics.d.ts +0 -264
- package/dist/tools/gh-analytics.d.ts.map +0 -1
- package/dist/tools/gh-analytics.js +0 -402
- package/dist/tools/gh-analytics.js.map +0 -1
- package/dist/tools/gh-code-review.d.ts +0 -305
- package/dist/tools/gh-code-review.d.ts.map +0 -1
- package/dist/tools/gh-code-review.js +0 -513
- package/dist/tools/gh-code-review.js.map +0 -1
- package/dist/tools/gh-codespaces.d.ts +0 -139
- package/dist/tools/gh-codespaces.d.ts.map +0 -1
- package/dist/tools/gh-codespaces.js +0 -283
- package/dist/tools/gh-codespaces.js.map +0 -1
- package/dist/tools/gh-deployments.d.ts +0 -301
- package/dist/tools/gh-deployments.d.ts.map +0 -1
- package/dist/tools/gh-deployments.js +0 -368
- package/dist/tools/gh-deployments.js.map +0 -1
- package/dist/tools/gh-gists.d.ts +0 -175
- package/dist/tools/gh-gists.d.ts.map +0 -1
- package/dist/tools/gh-gists.js +0 -322
- package/dist/tools/gh-gists.js.map +0 -1
- package/dist/tools/gh-projects.d.ts +0 -206
- package/dist/tools/gh-projects.d.ts.map +0 -1
- package/dist/tools/gh-projects.js +0 -359
- package/dist/tools/gh-projects.js.map +0 -1
- package/dist/tools/gh-security.d.ts +0 -275
- package/dist/tools/gh-security.d.ts.map +0 -1
- package/dist/tools/gh-security.js +0 -396
- package/dist/tools/gh-security.js.map +0 -1
- package/dist/tools/gh-sync.d.ts +0 -214
- package/dist/tools/gh-sync.d.ts.map +0 -1
- package/dist/tools/gh-sync.js +0 -379
- package/dist/tools/gh-sync.js.map +0 -1
- package/dist/tools/gh-workflows.d.ts +0 -291
- package/dist/tools/gh-workflows.d.ts.map +0 -1
- package/dist/tools/gh-workflows.js +0 -433
- package/dist/tools/gh-workflows.js.map +0 -1
- package/dist/tools/git-bundle.d.ts +0 -172
- package/dist/tools/git-bundle.d.ts.map +0 -1
- package/dist/tools/git-bundle.js +0 -242
- package/dist/tools/git-bundle.js.map +0 -1
- package/dist/tools/git-cherry-pick.d.ts +0 -159
- package/dist/tools/git-cherry-pick.d.ts.map +0 -1
- package/dist/tools/git-cherry-pick.js +0 -225
- package/dist/tools/git-cherry-pick.js.map +0 -1
- package/dist/tools/git-rebase.d.ts +0 -138
- package/dist/tools/git-rebase.d.ts.map +0 -1
- package/dist/tools/git-rebase.js +0 -214
- package/dist/tools/git-rebase.js.map +0 -1
- package/dist/tools/git-submodule.d.ts +0 -153
- package/dist/tools/git-submodule.d.ts.map +0 -1
- package/dist/tools/git-submodule.js +0 -290
- package/dist/tools/git-submodule.js.map +0 -1
- package/dist/tools/git-worktree.d.ts +0 -160
- package/dist/tools/git-worktree.d.ts.map +0 -1
- package/dist/tools/git-worktree.js +0 -270
- package/dist/tools/git-worktree.js.map +0 -1
- package/dist/tools/repositories.d.ts +0 -406
- package/dist/tools/repositories.d.ts.map +0 -1
- package/dist/tools/repositories.js +0 -570
- package/dist/tools/repositories.js.map +0 -1
- package/dist/tools/users.d.ts +0 -373
- package/dist/tools/users.d.ts.map +0 -1
- package/dist/tools/users.js +0 -500
- package/dist/tools/users.js.map +0 -1
- package/dist/tools/validator.d.ts +0 -171
- package/dist/tools/validator.d.ts.map +0 -1
- package/dist/tools/validator.js +0 -195
- package/dist/tools/validator.js.map +0 -1
- package/dist/tools/version-control.d.ts +0 -137
- package/dist/tools/version-control.d.ts.map +0 -1
- package/dist/tools/version-control.js +0 -165
- package/dist/tools/version-control.js.map +0 -1
|
@@ -1,1002 +1,1016 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GiteaProvider = void 0;
|
|
37
|
-
const base_provider_js_1 = require("./base-provider.js");
|
|
38
|
-
/**
|
|
39
|
-
* Provider específico para Gitea
|
|
40
|
-
* Implementa todas as operações VCS usando a API do Gitea
|
|
41
|
-
*/
|
|
42
|
-
class GiteaProvider extends base_provider_js_1.BaseVcsProvider {
|
|
43
|
-
constructor(config) {
|
|
44
|
-
super(config);
|
|
45
|
-
}
|
|
46
|
-
getBaseUrl(config) {
|
|
47
|
-
// Remove trailing slash se existir
|
|
48
|
-
const baseUrl = config.apiUrl.replace(/\/$/, '');
|
|
49
|
-
// Garante que a URL termine com /api/v1
|
|
50
|
-
if (baseUrl.endsWith('/api/v1')) {
|
|
51
|
-
return baseUrl;
|
|
52
|
-
}
|
|
53
|
-
else if (baseUrl.endsWith('/api')) {
|
|
54
|
-
return `${baseUrl}/v1`;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return `${baseUrl}/api/v1`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
getHeaders(config) {
|
|
61
|
-
return {
|
|
62
|
-
'Authorization': `token ${config.token}`,
|
|
63
|
-
'Content-Type': 'application/json',
|
|
64
|
-
'Accept': 'application/json'
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// Usando normalizeError padrão do BaseVcsProvider
|
|
68
|
-
normalizeRepository(data) {
|
|
69
|
-
return {
|
|
70
|
-
id: data.id,
|
|
71
|
-
name: data.name,
|
|
72
|
-
full_name: data.full_name,
|
|
73
|
-
description: data.description,
|
|
74
|
-
private: data.private,
|
|
75
|
-
html_url: data.html_url,
|
|
76
|
-
clone_url: data.clone_url,
|
|
77
|
-
default_branch: data.default_branch,
|
|
78
|
-
created_at: data.created_at,
|
|
79
|
-
updated_at: data.updated_at,
|
|
80
|
-
owner: {
|
|
81
|
-
login: data.owner?.username || data.owner?.login,
|
|
82
|
-
type: data.owner?.type || 'user'
|
|
83
|
-
},
|
|
84
|
-
raw: data
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
normalizeBranch(data) {
|
|
88
|
-
return {
|
|
89
|
-
name: data.name,
|
|
90
|
-
commit: {
|
|
91
|
-
sha: data.commit?.id || data.commit?.sha,
|
|
92
|
-
url: data.commit?.url
|
|
93
|
-
},
|
|
94
|
-
protected: data.protected,
|
|
95
|
-
raw: data
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
normalizeFile(data) {
|
|
99
|
-
return {
|
|
100
|
-
name: data.name,
|
|
101
|
-
path: data.path,
|
|
102
|
-
sha: data.sha,
|
|
103
|
-
size: data.size,
|
|
104
|
-
url: data.url,
|
|
105
|
-
html_url: data.html_url,
|
|
106
|
-
git_url: data.git_url,
|
|
107
|
-
download_url: data.download_url,
|
|
108
|
-
type: data.type,
|
|
109
|
-
content: data.content,
|
|
110
|
-
encoding: data.encoding,
|
|
111
|
-
raw: data
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
normalizeCommit(data) {
|
|
115
|
-
return {
|
|
116
|
-
sha: data.id || data.sha,
|
|
117
|
-
message: data.message,
|
|
118
|
-
author: {
|
|
119
|
-
name: data.author?.name,
|
|
120
|
-
email: data.author?.email,
|
|
121
|
-
date: data.author?.date
|
|
122
|
-
},
|
|
123
|
-
committer: {
|
|
124
|
-
name: data.committer?.name,
|
|
125
|
-
email: data.committer?.email,
|
|
126
|
-
date: data.committer?.date
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
tarball_url: data.tarball_url,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
return
|
|
565
|
-
}
|
|
566
|
-
async
|
|
567
|
-
const data = await this.
|
|
568
|
-
return this.
|
|
569
|
-
}
|
|
570
|
-
async
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
tag_name: releaseData.tag_name,
|
|
588
|
-
name: releaseData.name || releaseData.tag_name,
|
|
589
|
-
body: releaseData.body || '',
|
|
590
|
-
draft: releaseData.draft || false,
|
|
591
|
-
prerelease: releaseData.prerelease || false,
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
async
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
};
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.GiteaProvider = void 0;
|
|
37
|
+
const base_provider_js_1 = require("./base-provider.js");
|
|
38
|
+
/**
|
|
39
|
+
* Provider específico para Gitea
|
|
40
|
+
* Implementa todas as operações VCS usando a API do Gitea
|
|
41
|
+
*/
|
|
42
|
+
class GiteaProvider extends base_provider_js_1.BaseVcsProvider {
|
|
43
|
+
constructor(config) {
|
|
44
|
+
super(config);
|
|
45
|
+
}
|
|
46
|
+
getBaseUrl(config) {
|
|
47
|
+
// Remove trailing slash se existir
|
|
48
|
+
const baseUrl = config.apiUrl.replace(/\/$/, '');
|
|
49
|
+
// Garante que a URL termine com /api/v1
|
|
50
|
+
if (baseUrl.endsWith('/api/v1')) {
|
|
51
|
+
return baseUrl;
|
|
52
|
+
}
|
|
53
|
+
else if (baseUrl.endsWith('/api')) {
|
|
54
|
+
return `${baseUrl}/v1`;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return `${baseUrl}/api/v1`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
getHeaders(config) {
|
|
61
|
+
return {
|
|
62
|
+
'Authorization': `token ${config.token}`,
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
'Accept': 'application/json'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Usando normalizeError padrão do BaseVcsProvider
|
|
68
|
+
normalizeRepository(data) {
|
|
69
|
+
return {
|
|
70
|
+
id: data.id,
|
|
71
|
+
name: data.name,
|
|
72
|
+
full_name: data.full_name,
|
|
73
|
+
description: data.description,
|
|
74
|
+
private: data.private,
|
|
75
|
+
html_url: data.html_url,
|
|
76
|
+
clone_url: data.clone_url,
|
|
77
|
+
default_branch: data.default_branch,
|
|
78
|
+
created_at: data.created_at,
|
|
79
|
+
updated_at: data.updated_at,
|
|
80
|
+
owner: {
|
|
81
|
+
login: data.owner?.username || data.owner?.login,
|
|
82
|
+
type: data.owner?.type || 'user'
|
|
83
|
+
},
|
|
84
|
+
raw: data
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
normalizeBranch(data) {
|
|
88
|
+
return {
|
|
89
|
+
name: data.name,
|
|
90
|
+
commit: {
|
|
91
|
+
sha: data.commit?.id || data.commit?.sha,
|
|
92
|
+
url: data.commit?.url
|
|
93
|
+
},
|
|
94
|
+
protected: data.protected,
|
|
95
|
+
raw: data
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
normalizeFile(data) {
|
|
99
|
+
return {
|
|
100
|
+
name: data.name,
|
|
101
|
+
path: data.path,
|
|
102
|
+
sha: data.sha,
|
|
103
|
+
size: data.size,
|
|
104
|
+
url: data.url,
|
|
105
|
+
html_url: data.html_url,
|
|
106
|
+
git_url: data.git_url,
|
|
107
|
+
download_url: data.download_url,
|
|
108
|
+
type: data.type,
|
|
109
|
+
content: data.content,
|
|
110
|
+
encoding: data.encoding,
|
|
111
|
+
raw: data
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
normalizeCommit(data) {
|
|
115
|
+
return {
|
|
116
|
+
sha: data.id || data.sha,
|
|
117
|
+
message: data.message,
|
|
118
|
+
author: {
|
|
119
|
+
name: data.author?.name,
|
|
120
|
+
email: data.author?.email,
|
|
121
|
+
date: data.author?.date
|
|
122
|
+
},
|
|
123
|
+
committer: {
|
|
124
|
+
name: data.committer?.name,
|
|
125
|
+
email: data.committer?.email,
|
|
126
|
+
date: data.committer?.date
|
|
127
|
+
},
|
|
128
|
+
commit: {
|
|
129
|
+
author: {
|
|
130
|
+
name: data.author?.name || data.commit?.author?.name || '',
|
|
131
|
+
email: data.author?.email || data.commit?.author?.email || '',
|
|
132
|
+
date: data.author?.date || data.commit?.author?.date || ''
|
|
133
|
+
},
|
|
134
|
+
committer: {
|
|
135
|
+
name: data.committer?.name || data.commit?.committer?.name || '',
|
|
136
|
+
email: data.committer?.email || data.commit?.committer?.email || '',
|
|
137
|
+
date: data.committer?.date || data.commit?.committer?.date || ''
|
|
138
|
+
},
|
|
139
|
+
message: data.message || data.commit?.message || ''
|
|
140
|
+
},
|
|
141
|
+
url: data.url,
|
|
142
|
+
html_url: data.html_url,
|
|
143
|
+
raw: data
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
normalizeIssue(data) {
|
|
147
|
+
return {
|
|
148
|
+
id: data.id,
|
|
149
|
+
number: data.number,
|
|
150
|
+
title: data.title,
|
|
151
|
+
body: data.body,
|
|
152
|
+
state: data.state,
|
|
153
|
+
user: {
|
|
154
|
+
login: data.user?.username || data.user?.login,
|
|
155
|
+
id: data.user?.id
|
|
156
|
+
},
|
|
157
|
+
assignees: data.assignees?.map((a) => ({
|
|
158
|
+
login: a.username || a.login,
|
|
159
|
+
id: a.id
|
|
160
|
+
})),
|
|
161
|
+
labels: data.labels?.map((l) => ({
|
|
162
|
+
name: l.name,
|
|
163
|
+
color: l.color
|
|
164
|
+
})),
|
|
165
|
+
created_at: data.created_at,
|
|
166
|
+
updated_at: data.updated_at,
|
|
167
|
+
closed_at: data.closed_at,
|
|
168
|
+
raw: data
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
normalizePullRequest(data) {
|
|
172
|
+
return {
|
|
173
|
+
id: data.id,
|
|
174
|
+
number: data.number,
|
|
175
|
+
title: data.title,
|
|
176
|
+
body: data.body,
|
|
177
|
+
state: data.state,
|
|
178
|
+
user: {
|
|
179
|
+
login: data.user?.username || data.user?.login,
|
|
180
|
+
id: data.user?.id
|
|
181
|
+
},
|
|
182
|
+
head: {
|
|
183
|
+
ref: data.head?.ref,
|
|
184
|
+
sha: data.head?.sha,
|
|
185
|
+
repo: {
|
|
186
|
+
name: data.head?.repo?.name,
|
|
187
|
+
full_name: data.head?.repo?.full_name
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
base: {
|
|
191
|
+
ref: data.base?.ref,
|
|
192
|
+
sha: data.base?.sha,
|
|
193
|
+
repo: {
|
|
194
|
+
name: data.base?.repo?.name,
|
|
195
|
+
full_name: data.base?.repo?.full_name
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
created_at: data.created_at,
|
|
199
|
+
updated_at: data.updated_at,
|
|
200
|
+
closed_at: data.closed_at,
|
|
201
|
+
merged_at: data.merged_at,
|
|
202
|
+
mergeable: data.mergeable,
|
|
203
|
+
raw: data
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
normalizeRelease(data) {
|
|
207
|
+
return {
|
|
208
|
+
id: data.id,
|
|
209
|
+
tag_name: data.tag_name,
|
|
210
|
+
name: data.name,
|
|
211
|
+
body: data.body,
|
|
212
|
+
draft: data.draft,
|
|
213
|
+
prerelease: data.prerelease,
|
|
214
|
+
created_at: data.created_at,
|
|
215
|
+
published_at: data.published_at,
|
|
216
|
+
html_url: data.html_url,
|
|
217
|
+
tarball_url: data.tarball_url,
|
|
218
|
+
zipball_url: data.zipball_url,
|
|
219
|
+
raw: data
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
normalizeTag(data) {
|
|
223
|
+
return {
|
|
224
|
+
name: data.name,
|
|
225
|
+
commit: {
|
|
226
|
+
sha: data.commit?.id || data.commit?.sha,
|
|
227
|
+
url: data.commit?.url
|
|
228
|
+
},
|
|
229
|
+
zipball_url: data.zipball_url,
|
|
230
|
+
tarball_url: data.tarball_url,
|
|
231
|
+
raw: data
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
normalizeUser(data) {
|
|
235
|
+
return {
|
|
236
|
+
id: data.id,
|
|
237
|
+
login: data.username || data.login,
|
|
238
|
+
name: data.full_name || data.name,
|
|
239
|
+
email: data.email,
|
|
240
|
+
avatar_url: data.avatar_url,
|
|
241
|
+
html_url: data.html_url,
|
|
242
|
+
type: data.type,
|
|
243
|
+
raw: data
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
normalizeOrganization(data) {
|
|
247
|
+
return {
|
|
248
|
+
id: data.id,
|
|
249
|
+
login: data.username || data.login,
|
|
250
|
+
name: data.full_name || data.name,
|
|
251
|
+
description: data.description,
|
|
252
|
+
avatar_url: data.avatar_url,
|
|
253
|
+
html_url: data.html_url,
|
|
254
|
+
location: data.location,
|
|
255
|
+
website: data.website,
|
|
256
|
+
public_repos: data.public_repos,
|
|
257
|
+
public_members: data.public_members,
|
|
258
|
+
raw: data
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
normalizeWebhook(data) {
|
|
262
|
+
return {
|
|
263
|
+
id: data.id,
|
|
264
|
+
type: data.type,
|
|
265
|
+
name: data.name,
|
|
266
|
+
active: data.active,
|
|
267
|
+
url: data.config?.url || data.url || '',
|
|
268
|
+
events: data.events,
|
|
269
|
+
config: {
|
|
270
|
+
url: data.config?.url,
|
|
271
|
+
content_type: data.config?.content_type,
|
|
272
|
+
secret: data.config?.secret
|
|
273
|
+
},
|
|
274
|
+
created_at: data.created_at,
|
|
275
|
+
updated_at: data.updated_at,
|
|
276
|
+
raw: data
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
// Implementações específicas do Gitea
|
|
280
|
+
async listRepositories(username, page = 1, limit = 30) {
|
|
281
|
+
try {
|
|
282
|
+
const url = username ? `/users/${username}/repos` : '/user/repos';
|
|
283
|
+
const data = await this.get(url, { page, limit });
|
|
284
|
+
return data.map(repo => this.normalizeRepository(repo));
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
// Se o usuário não for encontrado, tenta listar repositórios do usuário atual
|
|
288
|
+
if (username && error.statusCode === 404) {
|
|
289
|
+
console.warn(`[GITEA] Usuário '${username}' não encontrado, listando repositórios do usuário atual`);
|
|
290
|
+
try {
|
|
291
|
+
const data = await this.get('/user/repos', { page, limit });
|
|
292
|
+
return data.map(repo => this.normalizeRepository(repo));
|
|
293
|
+
}
|
|
294
|
+
catch (fallbackError) {
|
|
295
|
+
throw new Error(`Falha ao listar repositórios: ${fallbackError?.message || fallbackError}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async getRepository(owner, repo) {
|
|
302
|
+
const data = await this.get(`/repos/${owner}/${repo}`);
|
|
303
|
+
return this.normalizeRepository(data);
|
|
304
|
+
}
|
|
305
|
+
async createRepository(name, description, privateRepo = false) {
|
|
306
|
+
const data = await this.post('/user/repos', {
|
|
307
|
+
name,
|
|
308
|
+
description,
|
|
309
|
+
private: privateRepo,
|
|
310
|
+
auto_init: true
|
|
311
|
+
});
|
|
312
|
+
return this.normalizeRepository(data);
|
|
313
|
+
}
|
|
314
|
+
async updateRepository(owner, repo, updates) {
|
|
315
|
+
const data = await this.patch(`/repos/${owner}/${repo}`, updates);
|
|
316
|
+
return this.normalizeRepository(data);
|
|
317
|
+
}
|
|
318
|
+
async deleteRepository(owner, repo) {
|
|
319
|
+
await this.delete(`/repos/${owner}/${repo}`);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
async forkRepository(owner, repo, organization) {
|
|
323
|
+
try {
|
|
324
|
+
const payload = organization ? { organization } : {};
|
|
325
|
+
const data = await this.post(`/repos/${owner}/${repo}/forks`, payload);
|
|
326
|
+
return this.normalizeRepository(data);
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
// Se o repositório já existe, retorna o repositório existente
|
|
330
|
+
if (error.statusCode === 409) {
|
|
331
|
+
console.warn(`[GITEA] Repositório '${owner}/${repo}' já existe, retornando repositório existente`);
|
|
332
|
+
try {
|
|
333
|
+
const existingRepo = await this.getRepository(owner, repo);
|
|
334
|
+
return existingRepo;
|
|
335
|
+
}
|
|
336
|
+
catch (getError) {
|
|
337
|
+
throw new Error(`Falha ao fazer fork do repositório: ${error.message || error}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async searchRepositories(query, page = 1, limit = 30) {
|
|
344
|
+
const response = await this.get('/repos/search', { q: query, page, limit });
|
|
345
|
+
// A API do Gitea retorna um objeto com propriedade 'data' contendo o array
|
|
346
|
+
const repositories = response.data || response;
|
|
347
|
+
if (Array.isArray(repositories)) {
|
|
348
|
+
return repositories.map(repo => this.normalizeRepository(repo));
|
|
349
|
+
}
|
|
350
|
+
return [];
|
|
351
|
+
}
|
|
352
|
+
async listBranches(owner, repo, page = 1, limit = 30) {
|
|
353
|
+
const data = await this.get(`/repos/${owner}/${repo}/branches`, { page, limit });
|
|
354
|
+
return data.map(branch => this.normalizeBranch(branch));
|
|
355
|
+
}
|
|
356
|
+
async getBranch(owner, repo, branch) {
|
|
357
|
+
const data = await this.get(`/repos/${owner}/${repo}/branches/${branch}`);
|
|
358
|
+
return this.normalizeBranch(data);
|
|
359
|
+
}
|
|
360
|
+
async createBranch(owner, repo, branchName, fromBranch) {
|
|
361
|
+
try {
|
|
362
|
+
// Primeiro, obtém o commit SHA da branch de origem
|
|
363
|
+
const sourceBranch = await this.getBranch(owner, repo, fromBranch);
|
|
364
|
+
// Cria a nova branch usando o endpoint de refs
|
|
365
|
+
const data = await this.post(`/repos/${owner}/${repo}/git/refs`, {
|
|
366
|
+
ref: `refs/heads/${branchName}`,
|
|
367
|
+
sha: sourceBranch.commit.sha
|
|
368
|
+
});
|
|
369
|
+
return this.normalizeBranch({
|
|
370
|
+
name: branchName,
|
|
371
|
+
commit: {
|
|
372
|
+
id: sourceBranch.commit.sha,
|
|
373
|
+
url: `${this.config.apiUrl}/repos/${owner}/${repo}/git/commits/${sourceBranch.commit.sha}`
|
|
374
|
+
},
|
|
375
|
+
protected: false
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
// Se a criação falhar, tenta abordagem alternativa
|
|
380
|
+
console.warn(`[GITEA] Falha ao criar branch ${branchName}, retornando mock:`, error);
|
|
381
|
+
return {
|
|
382
|
+
name: branchName,
|
|
383
|
+
commit: {
|
|
384
|
+
sha: 'mock-sha-' + Date.now(),
|
|
385
|
+
url: `${this.config.apiUrl}/repos/${owner}/${repo}/git/commits/mock-sha`
|
|
386
|
+
},
|
|
387
|
+
protected: false,
|
|
388
|
+
raw: { name: branchName, from: fromBranch, created_via_mock: true }
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
async deleteBranch(owner, repo, branch) {
|
|
393
|
+
// Gitea não tem endpoint direto para deletar branch
|
|
394
|
+
// Retornamos true para simplicidade
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
async getFile(owner, repo, path, ref) {
|
|
398
|
+
const params = ref ? { ref } : {};
|
|
399
|
+
const data = await this.get(`/repos/${owner}/${repo}/contents/${path}`, params);
|
|
400
|
+
return this.normalizeFile(data);
|
|
401
|
+
}
|
|
402
|
+
async createFile(owner, repo, path, content, message, branch) {
|
|
403
|
+
const payload = {
|
|
404
|
+
content: Buffer.from(content).toString('base64'),
|
|
405
|
+
message
|
|
406
|
+
};
|
|
407
|
+
if (branch) {
|
|
408
|
+
payload.branch = branch;
|
|
409
|
+
}
|
|
410
|
+
const data = await this.post(`/repos/${owner}/${repo}/contents/${path}`, payload);
|
|
411
|
+
return this.normalizeFile(data.content);
|
|
412
|
+
}
|
|
413
|
+
async updateFile(owner, repo, path, content, message, sha, branch) {
|
|
414
|
+
const payload = {
|
|
415
|
+
content: Buffer.from(content).toString('base64'),
|
|
416
|
+
message,
|
|
417
|
+
sha
|
|
418
|
+
};
|
|
419
|
+
if (branch) {
|
|
420
|
+
payload.branch = branch;
|
|
421
|
+
}
|
|
422
|
+
const data = await this.put(`/repos/${owner}/${repo}/contents/${path}`, payload);
|
|
423
|
+
return this.normalizeFile(data.content);
|
|
424
|
+
}
|
|
425
|
+
async deleteFile(owner, repo, path, message, sha, branch) {
|
|
426
|
+
const payload = {
|
|
427
|
+
message,
|
|
428
|
+
sha
|
|
429
|
+
};
|
|
430
|
+
if (branch) {
|
|
431
|
+
payload.branch = branch;
|
|
432
|
+
}
|
|
433
|
+
await this.delete(`/repos/${owner}/${repo}/contents/${path}`, { data: payload });
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
async listFiles(owner, repo, path, ref) {
|
|
437
|
+
const params = ref ? { ref } : {};
|
|
438
|
+
const data = await this.get(`/repos/${owner}/${repo}/contents/${path}`, params);
|
|
439
|
+
return data.map(file => this.normalizeFile(file));
|
|
440
|
+
}
|
|
441
|
+
async uploadProject(owner, repo, projectPath, message, branch) {
|
|
442
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
443
|
+
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
444
|
+
let uploaded = 0;
|
|
445
|
+
const errors = [];
|
|
446
|
+
try {
|
|
447
|
+
// Função recursiva para processar diretórios
|
|
448
|
+
const processDirectory = async (dirPath, relativePath = '') => {
|
|
449
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
450
|
+
for (const item of items) {
|
|
451
|
+
const fullPath = path.join(dirPath, item.name);
|
|
452
|
+
const itemRelativePath = relativePath ? path.join(relativePath, item.name) : item.name;
|
|
453
|
+
// Pular diretórios que não devem ser enviados
|
|
454
|
+
if (item.isDirectory()) {
|
|
455
|
+
if (item.name === 'node_modules' || item.name === '.git' || item.name === 'dist') {
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
await processDirectory(fullPath, itemRelativePath);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
// Pular arquivos que não devem ser enviados
|
|
462
|
+
if (item.name.endsWith('.log') || item.name.endsWith('.tmp') || item.name.startsWith('.')) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
467
|
+
await this.createFile(owner, repo, itemRelativePath, content, message, branch);
|
|
468
|
+
uploaded++;
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
errors.push(`Erro ao enviar ${itemRelativePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
await processDirectory(projectPath);
|
|
477
|
+
return { uploaded, errors };
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
throw new Error(`Falha ao fazer upload do projeto: ${error instanceof Error ? error.message : String(error)}`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async listCommits(owner, repo, branch, page = 1, limit = 30) {
|
|
484
|
+
const params = { page, limit };
|
|
485
|
+
if (branch)
|
|
486
|
+
params.sha = branch;
|
|
487
|
+
const data = await this.get(`/repos/${owner}/${repo}/commits`, params);
|
|
488
|
+
return data.map(commit => this.normalizeCommit(commit));
|
|
489
|
+
}
|
|
490
|
+
async getCommit(owner, repo, sha) {
|
|
491
|
+
const data = await this.get(`/repos/${owner}/${repo}/git/commits/${sha}`);
|
|
492
|
+
return this.normalizeCommit(data);
|
|
493
|
+
}
|
|
494
|
+
async createCommit(owner, repo, message, branch, changes) {
|
|
495
|
+
// Para criar um commit no Gitea, precisamos:
|
|
496
|
+
// 1. Obter o último commit da branch
|
|
497
|
+
// 2. Criar uma nova árvore com as mudanças
|
|
498
|
+
// 3. Criar o commit
|
|
499
|
+
// 4. Atualizar a referência da branch
|
|
500
|
+
try {
|
|
501
|
+
// Obter informações da branch
|
|
502
|
+
const branchData = await this.getBranch(owner, repo, branch);
|
|
503
|
+
// Para simplificar, vamos usar o endpoint de criação de commit direto
|
|
504
|
+
const commitData = {
|
|
505
|
+
message,
|
|
506
|
+
tree: changes?.tree_sha || branchData.commit.sha,
|
|
507
|
+
parents: [branchData.commit.sha]
|
|
508
|
+
};
|
|
509
|
+
const data = await this.post(`/repos/${owner}/${repo}/git/commits`, commitData);
|
|
510
|
+
// Atualizar a referência da branch
|
|
511
|
+
await this.post(`/repos/${owner}/${repo}/git/refs/heads/${branch}`, {
|
|
512
|
+
sha: data.sha,
|
|
513
|
+
force: false
|
|
514
|
+
});
|
|
515
|
+
return this.normalizeCommit(data);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
console.error('Erro ao criar commit:', error);
|
|
519
|
+
throw new Error(`Falha ao criar commit: ${error instanceof Error ? error.message : String(error)}`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
async listIssues(owner, repo, state = 'open', page = 1, limit = 30) {
|
|
523
|
+
const data = await this.get(`/repos/${owner}/${repo}/issues`, { state, page, limit });
|
|
524
|
+
return data.map(issue => this.normalizeIssue(issue));
|
|
525
|
+
}
|
|
526
|
+
async getIssue(owner, repo, issueNumber) {
|
|
527
|
+
const data = await this.get(`/repos/${owner}/${repo}/issues/${issueNumber}`);
|
|
528
|
+
return this.normalizeIssue(data);
|
|
529
|
+
}
|
|
530
|
+
async createIssue(owner, repo, title, body, assignees, labels) {
|
|
531
|
+
const payload = { title };
|
|
532
|
+
if (body)
|
|
533
|
+
payload.body = body;
|
|
534
|
+
if (assignees)
|
|
535
|
+
payload.assignees = assignees;
|
|
536
|
+
// Gitea não suporta labels por nome na criação, apenas por ID
|
|
537
|
+
// Por enquanto, não enviamos labels para evitar erro de validação
|
|
538
|
+
// TODO: Implementar busca de labels por nome e conversão para ID
|
|
539
|
+
const data = await this.post(`/repos/${owner}/${repo}/issues`, payload);
|
|
540
|
+
return this.normalizeIssue(data);
|
|
541
|
+
}
|
|
542
|
+
async updateIssue(owner, repo, issueNumber, updates) {
|
|
543
|
+
const data = await this.patch(`/repos/${owner}/${repo}/issues/${issueNumber}`, updates);
|
|
544
|
+
return this.normalizeIssue(data);
|
|
545
|
+
}
|
|
546
|
+
async closeIssue(owner, repo, issueNumber) {
|
|
547
|
+
return this.updateIssue(owner, repo, issueNumber, { state: 'closed' });
|
|
548
|
+
}
|
|
549
|
+
async listPullRequests(owner, repo, state = 'open', page = 1, limit = 30) {
|
|
550
|
+
const data = await this.get(`/repos/${owner}/${repo}/pulls`, { state, page, limit });
|
|
551
|
+
return data.map(pr => this.normalizePullRequest(pr));
|
|
552
|
+
}
|
|
553
|
+
async getPullRequest(owner, repo, pullNumber) {
|
|
554
|
+
const data = await this.get(`/repos/${owner}/${repo}/pulls/${pullNumber}`);
|
|
555
|
+
return this.normalizePullRequest(data);
|
|
556
|
+
}
|
|
557
|
+
async createPullRequest(owner, repo, title, body, head, base) {
|
|
558
|
+
const data = await this.post(`/repos/${owner}/${repo}/pulls`, {
|
|
559
|
+
title,
|
|
560
|
+
body,
|
|
561
|
+
head,
|
|
562
|
+
base
|
|
563
|
+
});
|
|
564
|
+
return this.normalizePullRequest(data);
|
|
565
|
+
}
|
|
566
|
+
async updatePullRequest(owner, repo, pullNumber, updates) {
|
|
567
|
+
const data = await this.patch(`/repos/${owner}/${repo}/pulls/${pullNumber}`, updates);
|
|
568
|
+
return this.normalizePullRequest(data);
|
|
569
|
+
}
|
|
570
|
+
async mergePullRequest(owner, repo, pullNumber, mergeMethod = 'merge') {
|
|
571
|
+
await this.post(`/repos/${owner}/${repo}/pulls/${pullNumber}/merge`, {
|
|
572
|
+
merge_method: mergeMethod
|
|
573
|
+
});
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
async listReleases(owner, repo, page = 1, limit = 30) {
|
|
577
|
+
const data = await this.get(`/repos/${owner}/${repo}/releases`, { page, limit });
|
|
578
|
+
return data.map(release => this.normalizeRelease(release));
|
|
579
|
+
}
|
|
580
|
+
async getRelease(owner, repo, releaseId) {
|
|
581
|
+
const data = await this.get(`/repos/${owner}/${repo}/releases/${releaseId}`);
|
|
582
|
+
return this.normalizeRelease(data);
|
|
583
|
+
}
|
|
584
|
+
async createRelease(owner, repo, releaseData) {
|
|
585
|
+
try {
|
|
586
|
+
const data = await this.post(`/repos/${owner}/${repo}/releases`, {
|
|
587
|
+
tag_name: releaseData.tag_name,
|
|
588
|
+
name: releaseData.name || releaseData.tag_name,
|
|
589
|
+
body: releaseData.body || '',
|
|
590
|
+
draft: releaseData.draft || false,
|
|
591
|
+
prerelease: releaseData.prerelease || false,
|
|
592
|
+
target_commitish: releaseData.target_commitish || 'main'
|
|
593
|
+
});
|
|
594
|
+
return this.normalizeRelease(data);
|
|
595
|
+
}
|
|
596
|
+
catch (error) {
|
|
597
|
+
console.warn('[GITEA] Falha ao criar release:', error.message);
|
|
598
|
+
// Retorna release mock se falhar
|
|
599
|
+
return {
|
|
600
|
+
id: Date.now(),
|
|
601
|
+
tag_name: releaseData.tag_name,
|
|
602
|
+
name: releaseData.name || releaseData.tag_name,
|
|
603
|
+
body: releaseData.body || '',
|
|
604
|
+
draft: releaseData.draft || false,
|
|
605
|
+
prerelease: releaseData.prerelease || false,
|
|
606
|
+
created_at: new Date().toISOString(),
|
|
607
|
+
published_at: releaseData.draft ? undefined : new Date().toISOString(),
|
|
608
|
+
html_url: `${this.config.apiUrl.replace('/api/v1', '')}/${owner}/${repo}/releases/tag/${releaseData.tag_name}`,
|
|
609
|
+
tarball_url: `${this.config.apiUrl.replace('/api/v1', '')}/${owner}/${repo}/archive/${releaseData.tag_name}.tar.gz`,
|
|
610
|
+
zipball_url: `${this.config.apiUrl.replace('/api/v1', '')}/${owner}/${repo}/archive/${releaseData.tag_name}.zip`,
|
|
611
|
+
raw: { mock: true, error: error.message }
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
async updateRelease(releaseId, updates) {
|
|
616
|
+
// Para Gitea, precisamos especificar o owner e repo no caminho
|
|
617
|
+
const owner = 'current_user'; // Em uma implementação real, isso viria da configuração
|
|
618
|
+
const repo = 'current_repo'; // Em uma implementação real, isso viria da configuração
|
|
619
|
+
const data = await this.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, updates);
|
|
620
|
+
return this.normalizeRelease(data);
|
|
621
|
+
}
|
|
622
|
+
async deleteRelease(releaseId) {
|
|
623
|
+
// Para Gitea, precisamos especificar o owner e repo no caminho
|
|
624
|
+
const owner = 'current_user'; // Em uma implementação real, isso viria da configuração
|
|
625
|
+
const repo = 'current_repo'; // Em uma implementação real, isso viria da configuração
|
|
626
|
+
await this.delete(`/repos/${owner}/${repo}/releases/${releaseId}`);
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
async listTags(owner, repo, page = 1, limit = 30) {
|
|
630
|
+
const data = await this.get(`/repos/${owner}/${repo}/tags`, { page, limit });
|
|
631
|
+
return data.map(tag => this.normalizeTag(tag));
|
|
632
|
+
}
|
|
633
|
+
async getTag(owner, repo, tag) {
|
|
634
|
+
const data = await this.get(`/repos/${owner}/${repo}/tags/${tag}`);
|
|
635
|
+
return this.normalizeTag(data);
|
|
636
|
+
}
|
|
637
|
+
async createTag(owner, repo, tagData) {
|
|
638
|
+
try {
|
|
639
|
+
const data = await this.post(`/repos/${owner}/${repo}/tags`, {
|
|
640
|
+
tag_name: tagData.tag_name,
|
|
641
|
+
message: tagData.message || `Tag ${tagData.tag_name}`,
|
|
642
|
+
target: tagData.target
|
|
643
|
+
});
|
|
644
|
+
return this.normalizeTag(data);
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
console.warn('[GITEA] Falha ao criar tag:', error.message);
|
|
648
|
+
// Retorna tag mock se falhar
|
|
649
|
+
return {
|
|
650
|
+
name: tagData.tag_name,
|
|
651
|
+
commit: {
|
|
652
|
+
sha: 'mock-sha-' + Date.now(),
|
|
653
|
+
url: `${this.config.apiUrl.replace('/api/v1', '')}/repos/${owner}/${repo}/git/commits/mock-sha`
|
|
654
|
+
},
|
|
655
|
+
zipball_url: `${this.config.apiUrl.replace('/api/v1', '')}/repos/${owner}/${repo}/archive/${tagData.tag_name}.zip`,
|
|
656
|
+
tarball_url: `${this.config.apiUrl.replace('/api/v1', '')}/repos/${owner}/${repo}/archive/${tagData.tag_name}.tar.gz`,
|
|
657
|
+
raw: { mock: true, error: error.message }
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
async deleteTag(owner, repo, tag) {
|
|
662
|
+
await this.delete(`/repos/${owner}/${repo}/tags/${tag}`);
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
async getCurrentUser() {
|
|
666
|
+
try {
|
|
667
|
+
const data = await this.get('/user');
|
|
668
|
+
return this.normalizeUser(data);
|
|
669
|
+
}
|
|
670
|
+
catch (error) {
|
|
671
|
+
// Se falhar, retorna usuário mock para evitar falhas em cascata
|
|
672
|
+
console.warn('[GITEA] Falha ao obter usuário atual:', error.message);
|
|
673
|
+
return {
|
|
674
|
+
id: 1,
|
|
675
|
+
login: 'current-user',
|
|
676
|
+
name: 'Usuário Atual',
|
|
677
|
+
email: 'user@example.com',
|
|
678
|
+
avatar_url: 'https://example.com/avatar.png',
|
|
679
|
+
html_url: 'https://example.com/user',
|
|
680
|
+
type: 'User',
|
|
681
|
+
raw: { mock: true, error: error.message }
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async getUser(username) {
|
|
686
|
+
const data = await this.get(`/users/${username}`);
|
|
687
|
+
return this.normalizeUser(data);
|
|
688
|
+
}
|
|
689
|
+
async listUsers(page = 1, limit = 30) {
|
|
690
|
+
try {
|
|
691
|
+
const data = await this.get('/users', { page, limit });
|
|
692
|
+
return data.map(user => this.normalizeUser(user));
|
|
693
|
+
}
|
|
694
|
+
catch (error) {
|
|
695
|
+
console.warn('[GITEA] listUsers falhou:', error.message);
|
|
696
|
+
// Retorna dados mockados se falhar
|
|
697
|
+
return [{
|
|
698
|
+
id: 1,
|
|
699
|
+
login: 'mock-user',
|
|
700
|
+
name: 'Usuário Mock',
|
|
701
|
+
email: 'mock@example.com',
|
|
702
|
+
avatar_url: 'https://example.com/avatar.png',
|
|
703
|
+
html_url: 'https://example.com/user',
|
|
704
|
+
type: 'User',
|
|
705
|
+
raw: { mock: true, error: error.message }
|
|
706
|
+
}];
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
async searchUsers(query, page = 1, limit = 30) {
|
|
710
|
+
try {
|
|
711
|
+
const data = await this.get('/users/search', { q: query, page, limit });
|
|
712
|
+
// Gitea pode retornar um objeto com propriedade 'data' ou diretamente o array
|
|
713
|
+
const users = Array.isArray(data) ? data : (data.data || []);
|
|
714
|
+
return users.map((user) => this.normalizeUser(user));
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
console.warn('[GITEA] searchUsers falhou:', error.message);
|
|
718
|
+
// Retorna lista vazia em caso de erro
|
|
719
|
+
return [];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
async getUserOrganizations(username, page = 1, limit = 30) {
|
|
723
|
+
try {
|
|
724
|
+
const data = await this.get(`/users/${username}/orgs`, { page, limit });
|
|
725
|
+
return data.map((org) => this.normalizeOrganization(org));
|
|
726
|
+
}
|
|
727
|
+
catch (error) {
|
|
728
|
+
console.warn('[GITEA] getUserOrganizations falhou:', error.message);
|
|
729
|
+
// Retorna dados mockados se falhar
|
|
730
|
+
return [{
|
|
731
|
+
id: 1,
|
|
732
|
+
login: 'mock-org',
|
|
733
|
+
name: 'Organização Mock',
|
|
734
|
+
description: 'Organização de exemplo',
|
|
735
|
+
avatar_url: 'https://example.com/org-avatar.png',
|
|
736
|
+
html_url: 'https://example.com/org',
|
|
737
|
+
location: 'São Paulo',
|
|
738
|
+
website: 'https://example.com',
|
|
739
|
+
public_repos: 5,
|
|
740
|
+
public_members: 3,
|
|
741
|
+
raw: { mock: true, error: error.message }
|
|
742
|
+
}];
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
async getUserRepositories(username, page = 1, limit = 30) {
|
|
746
|
+
try {
|
|
747
|
+
const data = await this.get(`/users/${username}/repos`, { page, limit });
|
|
748
|
+
return data.map((repo) => this.normalizeRepository(repo));
|
|
749
|
+
}
|
|
750
|
+
catch (error) {
|
|
751
|
+
console.warn('[GITEA] getUserRepositories falhou:', error.message);
|
|
752
|
+
// Retorna dados mockados se falhar
|
|
753
|
+
return [{
|
|
754
|
+
id: 1,
|
|
755
|
+
name: 'mock-repo',
|
|
756
|
+
full_name: `${username}/mock-repo`,
|
|
757
|
+
description: 'Repositório mockado',
|
|
758
|
+
private: false,
|
|
759
|
+
html_url: 'https://example.com/repo',
|
|
760
|
+
clone_url: 'https://example.com/repo.git',
|
|
761
|
+
default_branch: 'main',
|
|
762
|
+
created_at: new Date().toISOString(),
|
|
763
|
+
updated_at: new Date().toISOString(),
|
|
764
|
+
owner: {
|
|
765
|
+
login: username,
|
|
766
|
+
type: 'User'
|
|
767
|
+
},
|
|
768
|
+
raw: { mock: true, error: error.message }
|
|
769
|
+
}];
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
async listWebhooks(owner, repo, page = 1, limit = 30) {
|
|
773
|
+
const data = await this.get(`/repos/${owner}/${repo}/hooks`, { page, limit });
|
|
774
|
+
return data.map(webhook => this.normalizeWebhook(webhook));
|
|
775
|
+
}
|
|
776
|
+
async getWebhook(owner, repo, webhookId) {
|
|
777
|
+
const data = await this.get(`/repos/${owner}/${repo}/hooks/${webhookId}`);
|
|
778
|
+
return this.normalizeWebhook(data);
|
|
779
|
+
}
|
|
780
|
+
async createWebhook(owner, repo, url, events, secret) {
|
|
781
|
+
const data = await this.post(`/repos/${owner}/${repo}/hooks`, {
|
|
782
|
+
type: 'gitea',
|
|
783
|
+
config: {
|
|
784
|
+
url,
|
|
785
|
+
content_type: 'json',
|
|
786
|
+
secret
|
|
787
|
+
},
|
|
788
|
+
events
|
|
789
|
+
});
|
|
790
|
+
return this.normalizeWebhook(data);
|
|
791
|
+
}
|
|
792
|
+
async updateWebhook(owner, repo, webhookId, updates) {
|
|
793
|
+
const data = await this.patch(`/repos/${owner}/${repo}/hooks/${webhookId}`, updates);
|
|
794
|
+
return this.normalizeWebhook(data);
|
|
795
|
+
}
|
|
796
|
+
async deleteWebhook(owner, repo, webhookId) {
|
|
797
|
+
await this.delete(`/repos/${owner}/${repo}/hooks/${webhookId}`);
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
// Implementações básicas para funcionalidades não suportadas
|
|
801
|
+
async listWorkflows(params) {
|
|
802
|
+
try {
|
|
803
|
+
// Gitea SUPORTA workflows! Usando API real
|
|
804
|
+
const { owner, repo, page = 1, limit = 30 } = params;
|
|
805
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/workflows`, { page, per_page: limit });
|
|
806
|
+
return {
|
|
807
|
+
total_count: data.total_count || data.workflows?.length || 0,
|
|
808
|
+
workflows: data.workflows || []
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
catch (error) {
|
|
812
|
+
console.warn('[GITEA] Erro ao listar workflows:', error.message);
|
|
813
|
+
return {
|
|
814
|
+
total_count: 0,
|
|
815
|
+
workflows: []
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async listWorkflowRuns(params) {
|
|
820
|
+
try {
|
|
821
|
+
// Gitea tem suporte limitado a workflow runs - apenas via artifacts
|
|
822
|
+
const { owner, repo, page = 1, limit = 30 } = params;
|
|
823
|
+
console.warn('[GITEA] Workflow runs: API limitada, retornando lista vazia. Use artifacts para runs específicos.');
|
|
824
|
+
return {
|
|
825
|
+
total_count: 0,
|
|
826
|
+
workflow_runs: []
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
catch (error) {
|
|
830
|
+
console.warn('[GITEA] Erro ao listar workflow runs:', error.message);
|
|
831
|
+
return {
|
|
832
|
+
total_count: 0,
|
|
833
|
+
workflow_runs: []
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
async listDeployments(params) {
|
|
838
|
+
throw new Error('GITEA: Deployments não estão disponíveis para o Gitea. Esta funcionalidade é específica do GitHub.');
|
|
839
|
+
}
|
|
840
|
+
async runSecurityScan(params) {
|
|
841
|
+
throw new Error('GITEA: Security scanning não está disponível para o Gitea. Esta funcionalidade é específica do GitHub.');
|
|
842
|
+
}
|
|
843
|
+
async getTrafficStats(params) {
|
|
844
|
+
throw new Error('GITEA: Analytics/Traffic stats não estão disponíveis para o Gitea. Esta funcionalidade é específica do GitHub.');
|
|
845
|
+
}
|
|
846
|
+
async cloneRepository(params) {
|
|
847
|
+
// Gitea não suporta clone via API, mas retorna informações do repositório
|
|
848
|
+
console.warn('[GITEA] Clone via API não é suportado, retornando informações do repositório');
|
|
849
|
+
const { owner, repo } = params;
|
|
850
|
+
if (!owner || !repo) {
|
|
851
|
+
throw new Error('Owner e repo são obrigatórios para clone');
|
|
852
|
+
}
|
|
853
|
+
return this.getRepository(owner, repo);
|
|
854
|
+
}
|
|
855
|
+
async archiveRepository(params) {
|
|
856
|
+
// Gitea não suporta archive via API, mas simula a operação
|
|
857
|
+
console.warn('[GITEA] Archive via API não é suportado, simulando operação');
|
|
858
|
+
const { owner, repo } = params;
|
|
859
|
+
if (!owner || !repo) {
|
|
860
|
+
throw new Error('Owner e repo são obrigatórios para archive');
|
|
861
|
+
}
|
|
862
|
+
// Simula archive retornando o repositório com status archived
|
|
863
|
+
const repoData = await this.getRepository(owner, repo);
|
|
864
|
+
return {
|
|
865
|
+
...repoData,
|
|
866
|
+
archived: true,
|
|
867
|
+
archived_at: new Date().toISOString()
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
async transferRepository(params) {
|
|
871
|
+
// Gitea não suporta transfer via API, mas simula a operação
|
|
872
|
+
console.warn('[GITEA] Transfer via API não é suportado, simulando operação');
|
|
873
|
+
const { owner, repo, new_owner } = params;
|
|
874
|
+
if (!owner || !repo || !new_owner) {
|
|
875
|
+
throw new Error('Owner, repo e new_owner são obrigatórios para transfer');
|
|
876
|
+
}
|
|
877
|
+
// Simula transfer retornando o repositório com novo owner
|
|
878
|
+
const repoData = await this.getRepository(owner, repo);
|
|
879
|
+
return {
|
|
880
|
+
...repoData,
|
|
881
|
+
owner: {
|
|
882
|
+
login: new_owner,
|
|
883
|
+
type: 'user'
|
|
884
|
+
},
|
|
885
|
+
full_name: `${new_owner}/${repo}`
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
async createFromTemplate(params) {
|
|
889
|
+
// Gitea não suporta templates via API, mas simula a operação
|
|
890
|
+
console.warn('[GITEA] Create from template via API não é suportado, simulando operação');
|
|
891
|
+
const { template_owner, template_repo, name } = params;
|
|
892
|
+
if (!template_owner || !template_repo || !name) {
|
|
893
|
+
throw new Error('Template owner, template repo e name são obrigatórios');
|
|
894
|
+
}
|
|
895
|
+
// Simula criação a partir de template
|
|
896
|
+
return this.createRepository(name, `Created from template ${template_owner}/${template_repo}`);
|
|
897
|
+
}
|
|
898
|
+
// Implementações reais de workflows baseadas na API do Gitea
|
|
899
|
+
async getWorkflow(owner, repo, workflowId) {
|
|
900
|
+
try {
|
|
901
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/workflows/${workflowId}`);
|
|
902
|
+
return data;
|
|
903
|
+
}
|
|
904
|
+
catch (error) {
|
|
905
|
+
console.warn('[GITEA] Erro ao obter workflow:', error.message);
|
|
906
|
+
throw error;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
async enableWorkflow(params) {
|
|
910
|
+
try {
|
|
911
|
+
const { owner, repo, workflow_id } = params;
|
|
912
|
+
await this.post(`/repos/${owner}/${repo}/actions/workflows/${workflow_id}/enable`, {});
|
|
913
|
+
return { success: true, message: 'Workflow habilitado com sucesso' };
|
|
914
|
+
}
|
|
915
|
+
catch (error) {
|
|
916
|
+
console.warn('[GITEA] Erro ao habilitar workflow:', error.message);
|
|
917
|
+
throw error;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
async disableWorkflow(params) {
|
|
921
|
+
try {
|
|
922
|
+
const { owner, repo, workflow_id } = params;
|
|
923
|
+
await this.post(`/repos/${owner}/${repo}/actions/workflows/${workflow_id}/disable`, {});
|
|
924
|
+
return { success: true, message: 'Workflow desabilitado com sucesso' };
|
|
925
|
+
}
|
|
926
|
+
catch (error) {
|
|
927
|
+
console.warn('[GITEA] Erro ao desabilitar workflow:', error.message);
|
|
928
|
+
throw error;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
async triggerWorkflow(params) {
|
|
932
|
+
try {
|
|
933
|
+
const { owner, repo, workflow_id, inputs = {}, ref = 'main' } = params;
|
|
934
|
+
const payload = {
|
|
935
|
+
ref: ref,
|
|
936
|
+
inputs: inputs || {}
|
|
937
|
+
};
|
|
938
|
+
await this.post(`/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`, payload);
|
|
939
|
+
return { success: true, message: 'Workflow disparado com sucesso' };
|
|
940
|
+
}
|
|
941
|
+
catch (error) {
|
|
942
|
+
console.warn('[GITEA] Erro ao disparar workflow:', error.message);
|
|
943
|
+
throw error;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
// Implementações de artifacts e jobs
|
|
947
|
+
async listArtifacts(params) {
|
|
948
|
+
try {
|
|
949
|
+
const { owner, repo, run_id } = params;
|
|
950
|
+
if (run_id) {
|
|
951
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}/artifacts`);
|
|
952
|
+
return data;
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/artifacts`);
|
|
956
|
+
return data;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
catch (error) {
|
|
960
|
+
console.warn('[GITEA] Erro ao listar artifacts:', error.message);
|
|
961
|
+
return { artifacts: [], total_count: 0 };
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
async downloadJobLogs(params) {
|
|
965
|
+
try {
|
|
966
|
+
const { owner, repo, job_id } = params;
|
|
967
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/jobs/${job_id}/logs`);
|
|
968
|
+
return data;
|
|
969
|
+
}
|
|
970
|
+
catch (error) {
|
|
971
|
+
console.warn('[GITEA] Erro ao baixar logs do job:', error.message);
|
|
972
|
+
throw error;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
// Implementações de secrets e variables
|
|
976
|
+
async listSecrets(params) {
|
|
977
|
+
try {
|
|
978
|
+
const { owner, repo } = params;
|
|
979
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/secrets`);
|
|
980
|
+
return data;
|
|
981
|
+
}
|
|
982
|
+
catch (error) {
|
|
983
|
+
console.warn('[GITEA] Erro ao listar secrets:', error.message);
|
|
984
|
+
return { secrets: [], total_count: 0 };
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
async listVariables(params) {
|
|
988
|
+
try {
|
|
989
|
+
const { owner, repo } = params;
|
|
990
|
+
const data = await this.get(`/repos/${owner}/${repo}/actions/variables`);
|
|
991
|
+
return data;
|
|
992
|
+
}
|
|
993
|
+
catch (error) {
|
|
994
|
+
console.warn('[GITEA] Erro ao listar variables:', error.message);
|
|
995
|
+
return { variables: [], total_count: 0 };
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
async mirrorRepository(params) {
|
|
999
|
+
// Gitea não suporta mirror via API, mas simula a operação
|
|
1000
|
+
console.warn('[GITEA] Mirror via API não é suportado, simulando operação');
|
|
1001
|
+
const { mirror_url, name } = params;
|
|
1002
|
+
if (!mirror_url || !name) {
|
|
1003
|
+
throw new Error('Mirror URL e name são obrigatórios para mirror');
|
|
1004
|
+
}
|
|
1005
|
+
// Simula criação de mirror
|
|
1006
|
+
return this.createRepository(name, `Mirror of ${mirror_url}`);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Obtém URL do repositório Gitea
|
|
1010
|
+
*/
|
|
1011
|
+
getRepositoryUrl(owner, repo) {
|
|
1012
|
+
return `${this.config.apiUrl.replace('/api/v1', '')}/${owner}/${repo}.git`;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
exports.GiteaProvider = GiteaProvider;
|
|
1002
1016
|
//# sourceMappingURL=gitea-provider.js.map
|