plugin-git-manager 1.3.1 → 1.3.3
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/LICENSE +201 -0
- package/dist/client/317.17ed0018e3e7db00.js +10 -0
- package/dist/client/453.fc3042c9740d8fab.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/317.d2466574d00f94d0.js +10 -0
- package/dist/client-v2/453.5e507c94c59277b1.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +2 -2
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/review-cutover.js +121 -7
- package/dist/server/plugin.js +90 -9
- package/dist/server/repository-access.js +41 -3
- package/dist/server/services/legacy-post-service.js +10 -6
- package/dist/server/services/review-service.js +30 -7
- package/dist/server/services/review-source.js +7 -4
- package/package.json +2 -2
- package/src/client/__tests__/CommitHistory.test.tsx +1 -8
- package/src/client/__tests__/ReviewHistory.test.tsx +1 -8
- package/src/client/__tests__/RunReviewButton.test.tsx +1 -8
- package/src/client/__tests__/workflowRoutes.test.ts +3 -10
- package/src/client/components/CommitHistory.tsx +1 -8
- package/src/client/components/ReviewFlows.tsx +53 -19
- package/src/client/components/ReviewHistory.tsx +1 -8
- package/src/client/components/RunReviewButton.tsx +1 -8
- package/src/client/index.tsx +11 -8
- package/src/client/workflowRoutes.ts +3 -18
- package/src/client-v2/plugin.tsx +11 -0
- package/src/server/__tests__/git-security.test.ts +1 -8
- package/src/server/__tests__/poller-lifecycle.test.ts +1 -8
- package/src/server/__tests__/repository-access.test.ts +1 -8
- package/src/server/__tests__/review-service.integration.test.ts +1 -8
- package/src/server/__tests__/review.test.ts +1 -8
- package/src/server/__tests__/smoke.test.ts +1 -8
- package/src/server/actions/git-actions.ts +1 -8
- package/src/server/actions/gitlab-api.ts +1 -8
- package/src/server/actions/poller.ts +1 -8
- package/src/server/actions/review-cutover.ts +135 -15
- package/src/server/actions/review.ts +1 -8
- package/src/server/actions/role-permissions.ts +1 -8
- package/src/server/ai-tools.ts +1 -8
- package/src/server/collections/gitCodeReviews.ts +1 -8
- package/src/server/collections/gitReviewCutover.ts +1 -8
- package/src/server/collections/gitReviewFlows.ts +1 -8
- package/src/server/collections/gitReviewInbox.ts +1 -8
- package/src/server/collections/gitReviewProjects.ts +1 -8
- package/src/server/collections/gitReviewRequests.ts +1 -8
- package/src/server/index.ts +1 -8
- package/src/server/plugin.ts +88 -8
- package/src/server/poller.ts +1 -8
- package/src/server/repository-access.ts +36 -9
- package/src/server/request-method-policy.ts +1 -8
- package/src/server/review-control-access.ts +1 -8
- package/src/server/services/__tests__/registry-content-service.test.ts +1 -8
- package/src/server/services/__tests__/review-source.test.ts +33 -8
- package/src/server/services/legacy-post-service.ts +11 -14
- package/src/server/services/registry-content-service.ts +1 -8
- package/src/server/services/review-service.ts +35 -21
- package/src/server/services/review-source.ts +8 -12
- package/src/server/utils/get-repo-account.ts +1 -8
- package/src/server/utils/url-security.ts +1 -8
- package/dist/client/941.1793e67472872992.js +0 -10
- package/dist/client-v2/941.b0d55429cd053f32.js +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-11-
|
|
1
|
+
{"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-11-20T05:35:30.590Z"}
|
|
@@ -36,25 +36,129 @@ __export(review_cutover_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(review_cutover_exports);
|
|
37
37
|
var import_repository_access = require("../repository-access");
|
|
38
38
|
function service(ctx) {
|
|
39
|
-
var _a, _b
|
|
40
|
-
|
|
41
|
-
if (!Array.isArray(roles) || !roles.includes("root") || !((_c = (_b = ctx.state) == null ? void 0 : _b.currentUser) == null ? void 0 : _c.id))
|
|
42
|
-
ctx.throw(403, "Permission denied");
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (!((_b = (_a = ctx.state) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.id)) ctx.throw(403, ctx.t("Permission denied", { ns: "plugin-git-manager" }));
|
|
43
41
|
const plugin = ctx.app.pm.get("plugin-git-manager") || ctx.app.pm.get("git-manager");
|
|
44
42
|
if (!(plugin == null ? void 0 : plugin.reviewService)) ctx.throw(503, "Git review workflow service is unavailable");
|
|
45
43
|
return plugin.reviewService;
|
|
46
44
|
}
|
|
45
|
+
function roles(ctx) {
|
|
46
|
+
var _a;
|
|
47
|
+
const current = (_a = ctx.state) == null ? void 0 : _a.currentRoles;
|
|
48
|
+
return Array.isArray(current) && current.every((role) => typeof role === "string") ? current : [];
|
|
49
|
+
}
|
|
50
|
+
async function allowed(ctx, repositoryId2, action) {
|
|
51
|
+
if (typeof repositoryId2 !== "string" && typeof repositoryId2 !== "number") {
|
|
52
|
+
return (0, import_repository_access.hasUnrestrictedRepositoryAccess)({ acl: ctx.app.acl, roles: roles(ctx), action });
|
|
53
|
+
}
|
|
54
|
+
return (0, import_repository_access.hasRepositoryAccess)({ acl: ctx.app.acl, roles: roles(ctx), repositoryId: repositoryId2, action });
|
|
55
|
+
}
|
|
56
|
+
async function repositoryId(ctx, collection, id) {
|
|
57
|
+
const row = await ctx.db.getRepository(collection).findOne({ filterByTk: id });
|
|
58
|
+
const value = row == null ? void 0 : row.repositoryId;
|
|
59
|
+
return typeof value === "string" || typeof value === "number" ? value : null;
|
|
60
|
+
}
|
|
61
|
+
async function requireRecordAccess(ctx, collection, id, action) {
|
|
62
|
+
if (typeof id !== "string" && typeof id !== "number") return;
|
|
63
|
+
const repoId = await repositoryId(ctx, collection, id);
|
|
64
|
+
if (repoId == null || !await allowed(ctx, repoId, action)) {
|
|
65
|
+
ctx.throw(403, ctx.t("Permission denied", { ns: "plugin-git-manager" }));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
47
68
|
async function reviewCutoverStatus(ctx, next) {
|
|
48
|
-
|
|
69
|
+
const unrestricted = await (0, import_repository_access.hasUnrestrictedRepositoryAccess)({
|
|
70
|
+
acl: ctx.app.acl,
|
|
71
|
+
roles: roles(ctx),
|
|
72
|
+
action: "reviewCutoverStatus"
|
|
73
|
+
});
|
|
74
|
+
const status = await service(ctx).cutoverStatus(
|
|
75
|
+
unrestricted ? void 0 : (repositoryId2) => allowed(ctx, repositoryId2, "reviewCutoverStatus")
|
|
76
|
+
);
|
|
77
|
+
const repositoryCache = /* @__PURE__ */ new Map();
|
|
78
|
+
const findRepository = async (collection, id) => {
|
|
79
|
+
const key = `${collection}:${id}`;
|
|
80
|
+
if (!repositoryCache.has(key)) repositoryCache.set(key, await repositoryId(ctx, collection, id));
|
|
81
|
+
return repositoryCache.get(key) ?? null;
|
|
82
|
+
};
|
|
83
|
+
const visible = async (items, getRepositoryId, action) => {
|
|
84
|
+
const result = [];
|
|
85
|
+
for (const item of items) {
|
|
86
|
+
const repoId = await getRepositoryId(item);
|
|
87
|
+
if (!await allowed(ctx, repoId, "reviewCutoverStatus")) continue;
|
|
88
|
+
result.push({ ...item, canWrite: await allowed(ctx, repoId, action) });
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
const legacyPendingReviews = await visible(
|
|
93
|
+
status.legacyPendingReviews,
|
|
94
|
+
async (item) => item.repositoryId,
|
|
95
|
+
"reviewCancelLegacy"
|
|
96
|
+
);
|
|
97
|
+
const legacyRunningReviews = await visible(
|
|
98
|
+
status.legacyRunningReviews,
|
|
99
|
+
(item) => findRepository("gitCodeReviews", item.legacyReviewId),
|
|
100
|
+
"reviewRecover"
|
|
101
|
+
);
|
|
102
|
+
const legacyUncertainReviews = await visible(
|
|
103
|
+
status.legacyUncertainReviews,
|
|
104
|
+
async (item) => item.repositoryId,
|
|
105
|
+
"reviewRecover"
|
|
106
|
+
);
|
|
107
|
+
const quarantined = await visible(
|
|
108
|
+
status.quarantined,
|
|
109
|
+
(item) => findRepository("gitReviewRequests", item.requestId),
|
|
110
|
+
"reviewRecover"
|
|
111
|
+
);
|
|
112
|
+
const orphaned = await visible(
|
|
113
|
+
status.orphaned,
|
|
114
|
+
(item) => findRepository("gitReviewInbox", item.inboxId),
|
|
115
|
+
"reviewRecover"
|
|
116
|
+
);
|
|
117
|
+
const postUnknownReviews = await visible(
|
|
118
|
+
status.postUnknownReviews,
|
|
119
|
+
(item) => findRepository("gitCodeReviews", item.reviewId),
|
|
120
|
+
"reviewResetPostClaim"
|
|
121
|
+
);
|
|
122
|
+
const legacyPublicationHolds = await visible(
|
|
123
|
+
status.legacyPublicationHolds,
|
|
124
|
+
async (item) => item.repositoryId,
|
|
125
|
+
"reviewLegacyReleaseHold"
|
|
126
|
+
);
|
|
127
|
+
const queuedBlockedReviews = await visible(
|
|
128
|
+
status.queuedBlockedReviews,
|
|
129
|
+
async (item) => item.repositoryId,
|
|
130
|
+
"reviewCancelQueued"
|
|
131
|
+
);
|
|
132
|
+
ctx.body = {
|
|
133
|
+
success: true,
|
|
134
|
+
data: {
|
|
135
|
+
...status,
|
|
136
|
+
legacyPendingReviews,
|
|
137
|
+
legacyRunningReviews,
|
|
138
|
+
legacyUncertainReviews,
|
|
139
|
+
quarantined,
|
|
140
|
+
orphaned,
|
|
141
|
+
postUnknownReviews,
|
|
142
|
+
legacyPublicationHolds,
|
|
143
|
+
queuedBlockedReviews,
|
|
144
|
+
canConfirmCutover: await (0, import_repository_access.hasUnrestrictedRepositoryAccess)({
|
|
145
|
+
acl: ctx.app.acl,
|
|
146
|
+
roles: roles(ctx),
|
|
147
|
+
action: "reviewConfirmCutover"
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
};
|
|
49
151
|
await next();
|
|
50
152
|
}
|
|
51
153
|
async function reviewConfirmCutover(ctx, next) {
|
|
52
154
|
const reviewService = service(ctx);
|
|
155
|
+
if (!await (0, import_repository_access.hasUnrestrictedRepositoryAccess)({ acl: ctx.app.acl, roles: roles(ctx), action: "reviewConfirmCutover" })) {
|
|
156
|
+
ctx.throw(403, ctx.t("Permission denied", { ns: "plugin-git-manager" }));
|
|
157
|
+
}
|
|
53
158
|
if ((0, import_repository_access.getEffectiveActionParams)(ctx).confirmation !== "OLD_WORKERS_AND_AI_STOPPED")
|
|
54
159
|
ctx.throw(400, ctx.t("Worker and AI stop confirmation is required", { ns: "plugin-git-manager" }));
|
|
55
160
|
await reviewService.confirmCutover(ctx.state.currentUser.id);
|
|
56
|
-
ctx
|
|
57
|
-
await next();
|
|
161
|
+
await reviewCutoverStatus(ctx, next);
|
|
58
162
|
}
|
|
59
163
|
async function reviewCancelLegacy(ctx, next) {
|
|
60
164
|
const reviewService = service(ctx);
|
|
@@ -63,6 +167,7 @@ async function reviewCancelLegacy(ctx, next) {
|
|
|
63
167
|
ctx.throw(400, ctx.t("Legacy review cancellation confirmation is required", { ns: "plugin-git-manager" }));
|
|
64
168
|
if (typeof legacyReviewId !== "string" && typeof legacyReviewId !== "number")
|
|
65
169
|
ctx.throw(400, ctx.t("Legacy review identifier is required", { ns: "plugin-git-manager" }));
|
|
170
|
+
await requireRecordAccess(ctx, "gitCodeReviews", legacyReviewId, "reviewCancelLegacy");
|
|
66
171
|
await reviewService.cancelLegacy(legacyReviewId, ctx.state.currentUser.id);
|
|
67
172
|
ctx.body = { success: true };
|
|
68
173
|
await next();
|
|
@@ -72,6 +177,13 @@ async function reviewRecover(ctx, next) {
|
|
|
72
177
|
const { confirmation, requestId, executionId, legacyReviewId, inboxId } = (0, import_repository_access.getEffectiveActionParams)(ctx);
|
|
73
178
|
if (confirmation !== "AI_STOPPED")
|
|
74
179
|
ctx.throw(400, ctx.t("AI stop confirmation is required", { ns: "plugin-git-manager" }));
|
|
180
|
+
if (typeof legacyReviewId === "string" || typeof legacyReviewId === "number") {
|
|
181
|
+
await requireRecordAccess(ctx, "gitCodeReviews", legacyReviewId, "reviewRecover");
|
|
182
|
+
} else if (typeof inboxId === "string" || typeof inboxId === "number") {
|
|
183
|
+
await requireRecordAccess(ctx, "gitReviewInbox", inboxId, "reviewRecover");
|
|
184
|
+
} else {
|
|
185
|
+
await requireRecordAccess(ctx, "gitReviewRequests", requestId, "reviewRecover");
|
|
186
|
+
}
|
|
75
187
|
try {
|
|
76
188
|
if (typeof legacyReviewId === "string" || typeof legacyReviewId === "number") {
|
|
77
189
|
await reviewService.recoverLegacy(legacyReviewId, ctx.state.currentUser.id);
|
|
@@ -101,6 +213,7 @@ async function reviewResetPostClaim(ctx, next) {
|
|
|
101
213
|
if (confirmation !== "OUTBOUND_POST_STOPPED")
|
|
102
214
|
ctx.throw(400, ctx.t("Outbound post stop confirmation is required", { ns: "plugin-git-manager" }));
|
|
103
215
|
if (typeof reviewId !== "string" && typeof reviewId !== "number") ctx.throw(400, "reviewId is required");
|
|
216
|
+
await requireRecordAccess(ctx, "gitCodeReviews", reviewId, "reviewResetPostClaim");
|
|
104
217
|
if (!Object.prototype.hasOwnProperty.call(params, "expectedAttempt") || expectedAttempt !== null && typeof expectedAttempt !== "string") {
|
|
105
218
|
ctx.throw(400, ctx.t("Refresh publication status before recovery", { ns: "plugin-git-manager" }));
|
|
106
219
|
}
|
|
@@ -122,6 +235,7 @@ async function reviewCancelQueued(ctx, next) {
|
|
|
122
235
|
if (confirmation !== "CANCEL_QUEUED_REVIEW")
|
|
123
236
|
ctx.throw(400, ctx.t("Queued review cancellation confirmation is required", { ns: "plugin-git-manager" }));
|
|
124
237
|
if (typeof inboxId !== "string" && typeof inboxId !== "number") ctx.throw(400, "inboxId is required");
|
|
238
|
+
await requireRecordAccess(ctx, "gitReviewInbox", inboxId, "reviewCancelQueued");
|
|
125
239
|
await reviewService.cancelQueued(inboxId, ctx.state.currentUser.id);
|
|
126
240
|
ctx.body = { success: true };
|
|
127
241
|
await next();
|
package/dist/server/plugin.js
CHANGED
|
@@ -64,6 +64,15 @@ var import_repository_access = require("./repository-access");
|
|
|
64
64
|
var import_redact = require("./utils/redact");
|
|
65
65
|
var import_url_security = require("./utils/url-security");
|
|
66
66
|
const GIT_CONFIGURATION_URL_FIELDS = /* @__PURE__ */ new Set(["repoUrl", "baseUrl"]);
|
|
67
|
+
function isConcurrentSchemaChange(error) {
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
if (!error || typeof error !== "object") return false;
|
|
70
|
+
const databaseError = error;
|
|
71
|
+
const code = (_a = databaseError.original) == null ? void 0 : _a.code;
|
|
72
|
+
const number = (_b = databaseError.original) == null ? void 0 : _b.errno;
|
|
73
|
+
const message = ((_c = databaseError.original) == null ? void 0 : _c.message) || databaseError.message || "";
|
|
74
|
+
return ["42701", "42P07", "ER_DUP_FIELDNAME", "ER_DUP_KEYNAME"].includes(code || "") || number === 1060 || number === 1061 || /duplicate column name|index .* already exists/i.test(message);
|
|
75
|
+
}
|
|
67
76
|
function isGitConfigurationUrlMutation(resourceName, actionName) {
|
|
68
77
|
return typeof actionName === "string" && ["create", "update"].includes(actionName) && (0, import_redact.isGitManagerResourceResponse)(resourceName);
|
|
69
78
|
}
|
|
@@ -97,7 +106,7 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
97
106
|
});
|
|
98
107
|
}
|
|
99
108
|
async load() {
|
|
100
|
-
var _a;
|
|
109
|
+
var _a, _b;
|
|
101
110
|
const dayjsLib = require("dayjs");
|
|
102
111
|
const utcPlugin = require("dayjs/plugin/utc");
|
|
103
112
|
const timezonePlugin = require("dayjs/plugin/timezone");
|
|
@@ -154,6 +163,43 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
154
163
|
"reviewLegacyRetryPost"
|
|
155
164
|
]
|
|
156
165
|
});
|
|
166
|
+
for (const [action, aliases] of [
|
|
167
|
+
["fileContent", ["reviewCutoverStatus"]],
|
|
168
|
+
[
|
|
169
|
+
"triggerReview",
|
|
170
|
+
[
|
|
171
|
+
"reviewConfirmCutover",
|
|
172
|
+
"reviewCancelLegacy",
|
|
173
|
+
"reviewRecover",
|
|
174
|
+
"reviewResetPostClaim",
|
|
175
|
+
"reviewCancelQueued",
|
|
176
|
+
"reviewLegacyReleaseHold"
|
|
177
|
+
]
|
|
178
|
+
]
|
|
179
|
+
]) {
|
|
180
|
+
const registered = this.app.acl.getAvailableAction(action);
|
|
181
|
+
const previous = (_b = registered == null ? void 0 : registered.options) == null ? void 0 : _b.aliases;
|
|
182
|
+
this.app.acl.setAvailableAction(action, {
|
|
183
|
+
...registered == null ? void 0 : registered.options,
|
|
184
|
+
aliases: [...Array.isArray(previous) ? previous : previous ? [previous] : [], ...aliases]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
for (const action of ["list", "get", "create", "update", "destroy"]) {
|
|
188
|
+
this.app.acl.allow("gitReviewFlows", action, (ctx) => {
|
|
189
|
+
var _a2, _b2, _c;
|
|
190
|
+
const roles = (_a2 = ctx.state) == null ? void 0 : _a2.currentRoles;
|
|
191
|
+
if (!((_c = (_b2 = ctx.state) == null ? void 0 : _b2.currentUser) == null ? void 0 : _c.id) || !Array.isArray(roles)) return false;
|
|
192
|
+
const gitAction = action === "list" || action === "get" ? "fileContent" : "triggerReview";
|
|
193
|
+
return roles.some((role) => {
|
|
194
|
+
var _a3;
|
|
195
|
+
if (typeof role !== "string") return false;
|
|
196
|
+
const collection = (_a3 = ctx.app.acl.getRole(role)) == null ? void 0 : _a3.getResource("gitReviewFlows");
|
|
197
|
+
const permission = ctx.app.acl.can({ role, resource: "gitReviewFlows", action });
|
|
198
|
+
if (collection && !permission) return false;
|
|
199
|
+
return Boolean(ctx.app.acl.can({ role, resource: "gitManager", action: gitAction }));
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
157
203
|
this.app.resourceManager.use(import_request_method_policy.enforceGitRequestMethod);
|
|
158
204
|
this.app.resourceManager.use(import_review_control_access.enforceReviewControlAccess);
|
|
159
205
|
this.app.resourceManager.use(import_repository_access.enforceRepositoryAccess);
|
|
@@ -174,14 +220,20 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
174
220
|
this.app.on("afterStart", async () => {
|
|
175
221
|
await ensureAutoReviewFlowSchema(this.app).catch(
|
|
176
222
|
(err) => {
|
|
177
|
-
var _a2,
|
|
178
|
-
return (
|
|
223
|
+
var _a2, _b2;
|
|
224
|
+
return (_b2 = (_a2 = this.app.log) == null ? void 0 : _a2.error) == null ? void 0 : _b2.call(_a2, "plugin-git-manager: ensure schema error", err);
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
await this.ensureReviewSchema().catch(
|
|
228
|
+
(error) => {
|
|
229
|
+
var _a2, _b2;
|
|
230
|
+
return (_b2 = (_a2 = this.app.log) == null ? void 0 : _a2.error) == null ? void 0 : _b2.call(_a2, "plugin-git-manager: review schema error", error);
|
|
179
231
|
}
|
|
180
232
|
);
|
|
181
233
|
this.reviewService.start();
|
|
182
234
|
subtreeActions.recoverStuckSubtreeRuns(this.app).catch((err) => {
|
|
183
|
-
var _a2,
|
|
184
|
-
return (
|
|
235
|
+
var _a2, _b2;
|
|
236
|
+
return (_b2 = (_a2 = this.app.log) == null ? void 0 : _a2.error) == null ? void 0 : _b2.call(_a2, "plugin-git-manager: recover subtree runs error", err);
|
|
185
237
|
});
|
|
186
238
|
(0, import_poller.startPoller)(this.app);
|
|
187
239
|
});
|
|
@@ -222,7 +274,9 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
222
274
|
"gitManager:mergeRequestNotes",
|
|
223
275
|
"gitManager:pollerStatus",
|
|
224
276
|
"gitManager:subtreePreview",
|
|
225
|
-
"gitManager:subtreeOptions"
|
|
277
|
+
"gitManager:subtreeOptions",
|
|
278
|
+
"gitManager:reviewCutoverStatus",
|
|
279
|
+
"workflowGitReview:status"
|
|
226
280
|
]
|
|
227
281
|
});
|
|
228
282
|
this.app.acl.registerSnippet({
|
|
@@ -252,7 +306,15 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
252
306
|
"gitSubtreeConfigs:create",
|
|
253
307
|
"gitSubtreeConfigs:update",
|
|
254
308
|
"gitSubtreeConfigs:destroy",
|
|
255
|
-
"gitManager:subtreeRun"
|
|
309
|
+
"gitManager:subtreeRun",
|
|
310
|
+
"gitManager:reviewConfirmCutover",
|
|
311
|
+
"gitManager:reviewCancelLegacy",
|
|
312
|
+
"gitManager:reviewRecover",
|
|
313
|
+
"gitManager:reviewResetPostClaim",
|
|
314
|
+
"gitManager:reviewCancelQueued",
|
|
315
|
+
"gitManager:reviewLegacyReleaseHold",
|
|
316
|
+
"workflowGitReview:setup",
|
|
317
|
+
"workflowGitReview:repair"
|
|
256
318
|
]
|
|
257
319
|
});
|
|
258
320
|
this.app.acl.registerSnippet({
|
|
@@ -278,9 +340,9 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
278
340
|
]
|
|
279
341
|
});
|
|
280
342
|
this.app.resourceManager.use(async (ctx, next) => {
|
|
281
|
-
var _a2,
|
|
343
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
282
344
|
const resource = (_a2 = ctx.action) == null ? void 0 : _a2.resourceName;
|
|
283
|
-
if (resource === "gitSubtreeConfigs" && ["create", "update"].includes((
|
|
345
|
+
if (resource === "gitSubtreeConfigs" && ["create", "update"].includes((_b2 = ctx.action) == null ? void 0 : _b2.actionName) && ((_c = ctx.action.params) == null ? void 0 : _c.values)) {
|
|
284
346
|
try {
|
|
285
347
|
subtreeActions.validateSubtreeConfigInput(ctx.action.params.values);
|
|
286
348
|
} catch (error) {
|
|
@@ -356,6 +418,25 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
356
418
|
await ((_f = this.app.db.getCollection("gitReviewInbox")) == null ? void 0 : _f.sync());
|
|
357
419
|
await ((_g = this.app.db.getCollection("gitReviewRequests")) == null ? void 0 : _g.sync());
|
|
358
420
|
await ((_h = this.app.db.getCollection("gitReviewCutover")) == null ? void 0 : _h.sync());
|
|
421
|
+
await this.ensureReviewSchema();
|
|
422
|
+
}
|
|
423
|
+
async ensureReviewSchema() {
|
|
424
|
+
const lock = await this.app.lockManager.tryAcquire("git-manager-review-schema", 6e4);
|
|
425
|
+
await lock.runExclusive(async () => {
|
|
426
|
+
for (const name of ["gitReviewFlows", "gitCodeReviews"]) {
|
|
427
|
+
const collection = this.db.getCollection(name);
|
|
428
|
+
if (!collection) continue;
|
|
429
|
+
for (let attempt = 0; ; attempt++) {
|
|
430
|
+
try {
|
|
431
|
+
await collection.model.sync({ alter: { drop: false } });
|
|
432
|
+
break;
|
|
433
|
+
} catch (error) {
|
|
434
|
+
if (attempt >= 3 || !isConcurrentSchemaChange(error)) throw error;
|
|
435
|
+
await new Promise((resolve2) => setTimeout(resolve2, 50 * (attempt + 1)));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}, 3e5);
|
|
359
440
|
}
|
|
360
441
|
async beforeDisable() {
|
|
361
442
|
(0, import_review.unregisterReviewQueue)(this.app);
|
|
@@ -30,6 +30,7 @@ __export(repository_access_exports, {
|
|
|
30
30
|
enforceRepositoryCollectionAccess: () => enforceRepositoryCollectionAccess,
|
|
31
31
|
getEffectiveActionParams: () => getEffectiveActionParams,
|
|
32
32
|
hasRepositoryAccess: () => hasRepositoryAccess,
|
|
33
|
+
hasUnrestrictedRepositoryAccess: () => hasUnrestrictedRepositoryAccess,
|
|
33
34
|
resolveRepositoryScope: () => resolveRepositoryScope,
|
|
34
35
|
scopeIncludesRepository: () => scopeIncludesRepository
|
|
35
36
|
});
|
|
@@ -434,7 +435,7 @@ async function requireScopedRunConfigValue(ctx, values, scope, actionName) {
|
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
async function enforceRepositoryCollectionAccess(ctx, next) {
|
|
437
|
-
var _a, _b, _c, _d, _e, _f;
|
|
438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
438
439
|
const collectionName = scopedCollectionName(ctx);
|
|
439
440
|
if (!collectionName) {
|
|
440
441
|
await next();
|
|
@@ -454,6 +455,42 @@ async function enforceRepositoryCollectionAccess(ctx, next) {
|
|
|
454
455
|
}
|
|
455
456
|
}
|
|
456
457
|
const roles = currentRoles(ctx);
|
|
458
|
+
if (collectionName === "gitReviewFlows" && actionName && ["list", "get"].includes(actionName)) {
|
|
459
|
+
const readPermission = await ctx.app.acl.can({ roles, resource: "gitManager", action: "fileContent" });
|
|
460
|
+
if (readPermission) {
|
|
461
|
+
const readScope = resolveRepositoryScope((_e = readPermission.params) == null ? void 0 : _e.filter);
|
|
462
|
+
if (!readScope.supported) ctx.throw(403, "Permission denied");
|
|
463
|
+
if (!readScope.unrestricted) {
|
|
464
|
+
rejectScopedCredentialAssociationRoute(ctx);
|
|
465
|
+
rejectScopedRepositoryCredentialAssociationRead(ctx, actionName);
|
|
466
|
+
if (!((_f = ctx.action) == null ? void 0 : _f.mergeParams)) ctx.throw(403, "Permission denied");
|
|
467
|
+
ctx.action.mergeParams({ filter: collectionFilter(collectionName, readScope.ids) });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (collectionName === "gitReviewFlows" && actionName && ["create", "update", "destroy"].includes(actionName)) {
|
|
472
|
+
const writePermission = await ctx.app.acl.can({ roles, resource: "gitManager", action: "triggerReview" });
|
|
473
|
+
const readPermission = await ctx.app.acl.can({ roles, resource: "gitRepositories", action: "list" });
|
|
474
|
+
const hasGitManagerPermissions = roles.some((role) => {
|
|
475
|
+
var _a2, _b2, _c2;
|
|
476
|
+
return (_c2 = (_b2 = (_a2 = ctx.app.acl).getRole) == null ? void 0 : _b2.call(_a2, role)) == null ? void 0 : _c2.getResource("gitManager");
|
|
477
|
+
});
|
|
478
|
+
if (!writePermission && (readPermission || hasGitManagerPermissions)) ctx.throw(403, "Permission denied");
|
|
479
|
+
if (writePermission) {
|
|
480
|
+
const writeScope = resolveRepositoryScope((_g = writePermission.params) == null ? void 0 : _g.filter);
|
|
481
|
+
if (!writeScope.supported) ctx.throw(403, "Permission denied");
|
|
482
|
+
if (!writeScope.unrestricted) {
|
|
483
|
+
rejectScopedCredentialAssociationRoute(ctx);
|
|
484
|
+
if (actionName === "create" || actionName === "update") {
|
|
485
|
+
rejectScopedBulkMutationValues(ctx, actionName);
|
|
486
|
+
rejectScopedAssociationMutation(ctx, REPOSITORY_ASSOCIATION_SEGMENTS);
|
|
487
|
+
requireScopedRepositoryValue(ctx, effectiveMutationValues(ctx), writeScope, actionName);
|
|
488
|
+
}
|
|
489
|
+
if (!((_h = ctx.action) == null ? void 0 : _h.mergeParams)) ctx.throw(403, "Permission denied");
|
|
490
|
+
ctx.action.mergeParams({ filter: collectionFilter(collectionName, writeScope.ids) });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
457
494
|
if (roles.includes("root")) {
|
|
458
495
|
await next();
|
|
459
496
|
return;
|
|
@@ -467,7 +504,7 @@ async function enforceRepositoryCollectionAccess(ctx, next) {
|
|
|
467
504
|
await next();
|
|
468
505
|
return;
|
|
469
506
|
}
|
|
470
|
-
const scope = resolveRepositoryScope((
|
|
507
|
+
const scope = resolveRepositoryScope((_i = repositoryPermission.params) == null ? void 0 : _i.filter);
|
|
471
508
|
if (!scope.supported) {
|
|
472
509
|
ctx.throw(403, "Permission denied");
|
|
473
510
|
}
|
|
@@ -487,7 +524,7 @@ async function enforceRepositoryCollectionAccess(ctx, next) {
|
|
|
487
524
|
rejectScopedCredentialAssociationRoute(ctx);
|
|
488
525
|
rejectScopedRepositoryCredentialAssociationRead(ctx, actionName);
|
|
489
526
|
rejectScopedBulkMutationValues(ctx, actionName);
|
|
490
|
-
const mergeParams = (
|
|
527
|
+
const mergeParams = (_j = ctx.action) == null ? void 0 : _j.mergeParams;
|
|
491
528
|
if (!mergeParams) {
|
|
492
529
|
ctx.throw(403, "Permission denied");
|
|
493
530
|
}
|
|
@@ -583,6 +620,7 @@ async function enforceRepositoryAccess(ctx, next) {
|
|
|
583
620
|
enforceRepositoryCollectionAccess,
|
|
584
621
|
getEffectiveActionParams,
|
|
585
622
|
hasRepositoryAccess,
|
|
623
|
+
hasUnrestrictedRepositoryAccess,
|
|
586
624
|
resolveRepositoryScope,
|
|
587
625
|
scopeIncludesRepository
|
|
588
626
|
});
|
|
@@ -357,13 +357,8 @@ class LegacyPostService {
|
|
|
357
357
|
}
|
|
358
358
|
async releaseHold(reviewId, actor, roles, expectedAttempt) {
|
|
359
359
|
var _a, _b, _c;
|
|
360
|
-
if (!roles.includes("root")) {
|
|
361
|
-
const error = new Error("Permission denied");
|
|
362
|
-
error.status = 403;
|
|
363
|
-
throw error;
|
|
364
|
-
}
|
|
365
360
|
const currentRoles = await (0, import_review.resolveBackgroundReviewRoles)(this.app.db, actor);
|
|
366
|
-
if (!currentRoles.includes(
|
|
361
|
+
if (!roles.length || roles.some((role) => !currentRoles.includes(role))) {
|
|
367
362
|
const error = new Error("Permission denied");
|
|
368
363
|
error.status = 403;
|
|
369
364
|
throw error;
|
|
@@ -371,12 +366,21 @@ class LegacyPostService {
|
|
|
371
366
|
const review = await this.app.db.getRepository("gitCodeReviews").findOne({ filterByTk: reviewId });
|
|
372
367
|
if (!review || value(review, "status") !== "completed" || value(review, "targetType") !== "mr" || ((_a = value(review, "metadata")) == null ? void 0 : _a.workflowManaged) || await this.app.db.getRepository("gitReviewInbox").findOne({ filter: { reviewId } }))
|
|
373
368
|
conflict("Legacy review is not available");
|
|
369
|
+
const repositoryId = value(review, "repositoryId");
|
|
370
|
+
if (!await (0, import_repository_access.hasRepositoryAccess)({ acl: this.app.acl, roles, repositoryId, action: "reviewLegacyReleaseHold" })) {
|
|
371
|
+
const error = new Error("Permission denied");
|
|
372
|
+
error.status = 403;
|
|
373
|
+
throw error;
|
|
374
|
+
}
|
|
374
375
|
const projectKey = value(review, "legacyPostProjectKey") || ((_b = sourceOf(review)) == null ? void 0 : _b.projectKey);
|
|
375
376
|
if (!projectKey) conflict("Legacy review has no publication hold");
|
|
376
377
|
const db = this.app.db;
|
|
377
378
|
await db.sequelize.transaction(async (transaction) => {
|
|
378
379
|
var _a2;
|
|
379
380
|
const current = await db.getCollection("gitCodeReviews").model.findOne({ where: { id: reviewId }, transaction, lock: transaction.LOCK.UPDATE });
|
|
381
|
+
if (current && String(value(current, "repositoryId")) !== String(repositoryId)) {
|
|
382
|
+
conflict("Review repository changed");
|
|
383
|
+
}
|
|
380
384
|
if (!current || (value(current, "legacyPostClaim") ?? null) !== expectedAttempt || !["posting", "post_unknown", "post_failed"].includes(value(current, "postStatus")) || (value(current, "legacyPostProjectKey") || ((_a2 = sourceOf(current)) == null ? void 0 : _a2.projectKey)) !== projectKey)
|
|
381
385
|
conflict("Review publication claim changed");
|
|
382
386
|
const project = await db.getCollection("gitReviewProjects").model.findOne({ where: { projectKey }, transaction, lock: transaction.LOCK.UPDATE });
|
|
@@ -247,7 +247,7 @@ class GitReviewService {
|
|
|
247
247
|
}
|
|
248
248
|
return legacy;
|
|
249
249
|
}
|
|
250
|
-
async cutoverStatus() {
|
|
250
|
+
async cutoverStatus(canViewRepository) {
|
|
251
251
|
var _a, _b, _c;
|
|
252
252
|
const db = this.app.db;
|
|
253
253
|
const model = db.getCollection("gitReviewCutover").model;
|
|
@@ -267,8 +267,15 @@ class GitReviewService {
|
|
|
267
267
|
record = await model.findOne({ where: { key: "global" } });
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
const
|
|
271
|
-
|
|
270
|
+
const visibleRows = async (rows) => {
|
|
271
|
+
if (!canViewRepository) return rows;
|
|
272
|
+
const allowed = await Promise.all(rows.map((row) => canViewRepository(value(row, "repositoryId"))));
|
|
273
|
+
return rows.filter((_row, index) => allowed[index]);
|
|
274
|
+
};
|
|
275
|
+
const legacy = await visibleRows(await this.legacyRows());
|
|
276
|
+
const failed = await visibleRows(
|
|
277
|
+
await db.getRepository("gitCodeReviews").find({ filter: { status: "failed" }, sort: ["id"] })
|
|
278
|
+
);
|
|
272
279
|
const uncertain = [];
|
|
273
280
|
for (const review of failed) {
|
|
274
281
|
const metadata = value(review, "metadata");
|
|
@@ -276,7 +283,9 @@ class GitReviewService {
|
|
|
276
283
|
if (!await db.getRepository("gitReviewInbox").findOne({ filter: { reviewId: value(review, "id") } }))
|
|
277
284
|
uncertain.push(review);
|
|
278
285
|
}
|
|
279
|
-
const activeRows = await
|
|
286
|
+
const activeRows = await visibleRows(
|
|
287
|
+
await db.getRepository("gitReviewInbox").find({ filter: { state: { $in: ["dispatched", "running", "quarantined"] } }, sort: ["id"] })
|
|
288
|
+
);
|
|
280
289
|
const quarantined = [];
|
|
281
290
|
const orphaned = [];
|
|
282
291
|
const postUnknownReviews = [];
|
|
@@ -284,19 +293,33 @@ class GitReviewService {
|
|
|
284
293
|
const legacyProjects = await db.getRepository("gitReviewProjects").find({
|
|
285
294
|
filter: { legacyPostReviewId: { $ne: null } },
|
|
286
295
|
sort: ["id"],
|
|
287
|
-
limit: 100
|
|
296
|
+
...canViewRepository ? {} : { limit: 100 }
|
|
288
297
|
});
|
|
289
298
|
for (const project of legacyProjects) {
|
|
290
299
|
const reviewId = value(project, "legacyPostReviewId");
|
|
291
300
|
const heldReview = await db.getRepository("gitCodeReviews").findOne({ filterByTk: reviewId });
|
|
301
|
+
if (canViewRepository && !await canViewRepository(heldReview ? value(heldReview, "repositoryId") : null))
|
|
302
|
+
continue;
|
|
303
|
+
if (legacyPublicationHolds.length >= 100) break;
|
|
292
304
|
legacyPublicationHolds.push({
|
|
293
305
|
reviewId,
|
|
294
306
|
repositoryId: heldReview ? value(heldReview, "repositoryId") : null,
|
|
295
307
|
attemptId: heldReview ? value(heldReview, "legacyPostClaim") ?? null : null
|
|
296
308
|
});
|
|
297
309
|
}
|
|
298
|
-
const queuedBlocked = await
|
|
299
|
-
|
|
310
|
+
const queuedBlocked = (await visibleRows(
|
|
311
|
+
await db.getRepository("gitReviewInbox").find({
|
|
312
|
+
filter: { state: "queued", blockedReason: { $ne: null } },
|
|
313
|
+
sort: ["queuedAt", "id"],
|
|
314
|
+
...canViewRepository ? {} : { limit: 100 }
|
|
315
|
+
})
|
|
316
|
+
)).slice(0, 100);
|
|
317
|
+
const unresolved = await visibleRows(
|
|
318
|
+
await db.getRepository("gitCodeReviews").find({
|
|
319
|
+
filter: { postStatus: { $in: ["posting", "post_unknown", "post_failed", "retrying"] } },
|
|
320
|
+
sort: ["id"]
|
|
321
|
+
})
|
|
322
|
+
);
|
|
300
323
|
for (const review of unresolved) {
|
|
301
324
|
if (((_c = value(review, "metadata")) == null ? void 0 : _c.workflowManaged) && postUnknownReviews.length < 100) {
|
|
302
325
|
const inbox = await db.getRepository("gitReviewInbox").findOne({ filter: { reviewId: value(review, "id") } });
|
|
@@ -176,9 +176,11 @@ async function readPinnedReviewSource(db, repo, source) {
|
|
|
176
176
|
if (!Array.isArray(files) || files.length >= 300) throw new Error("GitHub comparison is incomplete");
|
|
177
177
|
content = files.map((item) => {
|
|
178
178
|
const file = object(item);
|
|
179
|
-
if (typeof file.filename !== "string"
|
|
180
|
-
throw new Error("GitHub comparison contains an unavailable patch");
|
|
179
|
+
if (typeof file.filename !== "string") throw new Error("GitHub comparison contains an unavailable patch");
|
|
181
180
|
if (/[\r\n]/.test(file.filename)) throw new Error("GitHub comparison has an unsupported filename");
|
|
181
|
+
if (typeof file.patch !== "string") {
|
|
182
|
+
return `Binary files a/${file.filename} and b/${file.filename} differ (patch omitted by provider)`;
|
|
183
|
+
}
|
|
182
184
|
return `--- a/${file.filename}
|
|
183
185
|
+++ b/${file.filename}
|
|
184
186
|
${file.patch}`;
|
|
@@ -193,11 +195,12 @@ ${file.patch}`;
|
|
|
193
195
|
}
|
|
194
196
|
content = comparison.diffs.map((item) => {
|
|
195
197
|
const file = object(item);
|
|
196
|
-
if (file.too_large || file.collapsed || typeof file.diff !== "string")
|
|
197
|
-
throw new Error("GitLab comparison contains an unavailable patch");
|
|
198
198
|
const oldPath = String(file.old_path || "");
|
|
199
199
|
const newPath = String(file.new_path || "");
|
|
200
200
|
if (/[\r\n]/.test(oldPath + newPath)) throw new Error("GitLab comparison has an unsupported filename");
|
|
201
|
+
if (file.too_large || file.collapsed || typeof file.diff !== "string") {
|
|
202
|
+
return `Binary files a/${oldPath} and b/${newPath} differ (patch omitted by provider)`;
|
|
203
|
+
}
|
|
201
204
|
return `--- a/${oldPath}
|
|
202
205
|
+++ b/${newPath}
|
|
203
206
|
${file.diff}`;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Git Manager",
|
|
4
4
|
"displayName.zh-CN": "Git 管理器",
|
|
5
5
|
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
-
"version": "1.3.
|
|
6
|
+
"version": "1.3.3",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"files": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"url": "git+https://github.com/OrgGem/nocobase-beta.git",
|
|
54
54
|
"directory": "packages/plugins/plugin-git-manager"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4161e515ff5a82d119caf92774d9f12ac79b3caf",
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public",
|
|
59
59
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import React from 'react';
|
|
11
4
|
import { cleanup, render, screen, waitFor } from '@testing-library/react';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import React from 'react';
|
|
11
4
|
import { cleanup, configure, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import React from 'react';
|
|
11
4
|
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
|