plugin-git-manager 1.3.2 → 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.
Files changed (52) hide show
  1. package/LICENSE +201 -0
  2. package/dist/client/{453.d49fac0e20ea08d9.js → 453.fc3042c9740d8fab.js} +1 -1
  3. package/dist/client/index.js +1 -1
  4. package/dist/client-v2/{453.84c4387ba605dc27.js → 453.5e507c94c59277b1.js} +1 -1
  5. package/dist/client-v2/index.js +1 -1
  6. package/dist/node_modules/simple-git/package.json +1 -1
  7. package/dist/node_modules/zod/package.json +1 -1
  8. package/dist/server/services/review-source.js +7 -4
  9. package/package.json +2 -2
  10. package/src/client/__tests__/CommitHistory.test.tsx +1 -8
  11. package/src/client/__tests__/ReviewHistory.test.tsx +1 -8
  12. package/src/client/__tests__/RunReviewButton.test.tsx +1 -8
  13. package/src/client/__tests__/workflowRoutes.test.ts +3 -10
  14. package/src/client/components/CommitHistory.tsx +1 -8
  15. package/src/client/components/ReviewFlows.tsx +1 -8
  16. package/src/client/components/ReviewHistory.tsx +1 -8
  17. package/src/client/components/RunReviewButton.tsx +1 -8
  18. package/src/client/index.tsx +1 -8
  19. package/src/client/workflowRoutes.ts +3 -18
  20. package/src/server/__tests__/git-security.test.ts +1 -8
  21. package/src/server/__tests__/poller-lifecycle.test.ts +1 -8
  22. package/src/server/__tests__/repository-access.test.ts +1 -8
  23. package/src/server/__tests__/review-service.integration.test.ts +1 -8
  24. package/src/server/__tests__/review.test.ts +1 -8
  25. package/src/server/__tests__/smoke.test.ts +1 -8
  26. package/src/server/actions/git-actions.ts +1 -8
  27. package/src/server/actions/gitlab-api.ts +1 -8
  28. package/src/server/actions/poller.ts +1 -8
  29. package/src/server/actions/review-cutover.ts +1 -8
  30. package/src/server/actions/review.ts +1 -8
  31. package/src/server/actions/role-permissions.ts +1 -8
  32. package/src/server/ai-tools.ts +1 -8
  33. package/src/server/collections/gitCodeReviews.ts +1 -8
  34. package/src/server/collections/gitReviewCutover.ts +1 -8
  35. package/src/server/collections/gitReviewFlows.ts +1 -8
  36. package/src/server/collections/gitReviewInbox.ts +1 -8
  37. package/src/server/collections/gitReviewProjects.ts +1 -8
  38. package/src/server/collections/gitReviewRequests.ts +1 -8
  39. package/src/server/index.ts +1 -8
  40. package/src/server/plugin.ts +1 -8
  41. package/src/server/poller.ts +1 -8
  42. package/src/server/repository-access.ts +1 -8
  43. package/src/server/request-method-policy.ts +1 -8
  44. package/src/server/review-control-access.ts +1 -8
  45. package/src/server/services/__tests__/registry-content-service.test.ts +1 -8
  46. package/src/server/services/__tests__/review-source.test.ts +33 -8
  47. package/src/server/services/legacy-post-service.ts +1 -8
  48. package/src/server/services/registry-content-service.ts +1 -8
  49. package/src/server/services/review-service.ts +1 -8
  50. package/src/server/services/review-source.ts +8 -12
  51. package/src/server/utils/get-repo-account.ts +1 -8
  52. package/src/server/utils/url-security.ts +1 -8
@@ -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
  export { default } from './plugin';
11
4
  export { PluginGitManagerServer } from './plugin';
@@ -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 { Plugin } from '@nocobase/server';
11
4
  import type { Context } from '@nocobase/actions';
@@ -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 type { Application } from '@nocobase/server';
11
4
  import { triggerReviewInternal, branchMatches } from './actions/review';
@@ -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
  const REPOSITORY_ID_ACTIONS = new Set([
11
4
  'clone',
@@ -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 type { Context } from '@nocobase/actions';
11
4
 
@@ -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 type { Context } from '@nocobase/actions';
11
4
 
@@ -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 { execFileSync } from 'child_process';
11
4
  import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'fs';
@@ -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 { execFileSync } from 'child_process';
11
4
  import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'fs';
@@ -223,4 +216,36 @@ describe('pinned Git review source', () => {
223
216
  `https://gitlab.test/api/v4/projects/team%2Fproject/repository/compare?from=${projectBase}&to=${projectHead}`,
224
217
  );
225
218
  });
219
+
220
+ it('marks collapsed or binary merge-request patches as omitted instead of failing the review context', async () => {
221
+ const fetchMock = vi.fn(async (input: string | URL | Request) => {
222
+ const url = String(input);
223
+ const body = url.includes('/repository/compare')
224
+ ? {
225
+ compare_timeout: false,
226
+ overflow: false,
227
+ diffs: [
228
+ { old_path: 'src/action.ts', new_path: 'src/action.ts', diff: '@@ -1 +1 @@\n-old()\n+new()' },
229
+ { old_path: 'yarn.lock', new_path: 'yarn.lock', collapsed: true, too_large: true, diff: '' },
230
+ ],
231
+ }
232
+ : url.includes('/merge_requests/9')
233
+ ? { sha: projectHead, diff_refs: { base_sha: projectBase }, source_branch: 'feature/review' }
234
+ : { id: 71, web_url: 'https://gitlab.test/team/project' };
235
+ return new Response(JSON.stringify(body), { status: 200, headers: { 'content-type': 'application/json' } });
236
+ });
237
+ vi.stubGlobal('fetch', fetchMock);
238
+ const database = createDatabase();
239
+ const repository = createRepository(1, 'https://gitlab.test/team/project.git');
240
+ const source = await resolveReviewSource(database, repository, {
241
+ targetType: 'mr',
242
+ mrIid: 9,
243
+ headSha: projectHead,
244
+ });
245
+
246
+ const diff = await readPinnedReviewSource(database, repository, source);
247
+
248
+ expect(diff).toContain('+new()');
249
+ expect(diff).toContain('Binary files a/yarn.lock and b/yarn.lock differ (patch omitted by provider)');
250
+ });
226
251
  });
@@ -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 { createHash, randomUUID } from 'crypto';
11
4
  import type { Application } from '@nocobase/server';
@@ -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 { spawn } from 'child_process';
11
4
  import { existsSync } from 'fs';
@@ -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 { createHash, randomUUID } from 'crypto';
11
4
  import type { Application } from '@nocobase/server';
@@ -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 { createHash } from 'crypto';
11
4
  import type { Database } from '@nocobase/database';
@@ -192,9 +185,11 @@ export async function readPinnedReviewSource(
192
185
  content = files
193
186
  .map((item) => {
194
187
  const file = object(item);
195
- if (typeof file.filename !== 'string' || typeof file.patch !== 'string')
196
- throw new Error('GitHub comparison contains an unavailable patch');
188
+ if (typeof file.filename !== 'string') throw new Error('GitHub comparison contains an unavailable patch');
197
189
  if (/[\r\n]/.test(file.filename)) throw new Error('GitHub comparison has an unsupported filename');
190
+ if (typeof file.patch !== 'string') {
191
+ return `Binary files a/${file.filename} and b/${file.filename} differ (patch omitted by provider)`;
192
+ }
198
193
  return `--- a/${file.filename}\n+++ b/${file.filename}\n${file.patch}`;
199
194
  })
200
195
  .join('\n');
@@ -209,11 +204,12 @@ export async function readPinnedReviewSource(
209
204
  content = comparison.diffs
210
205
  .map((item) => {
211
206
  const file = object(item);
212
- if (file.too_large || file.collapsed || typeof file.diff !== 'string')
213
- throw new Error('GitLab comparison contains an unavailable patch');
214
207
  const oldPath = String(file.old_path || '');
215
208
  const newPath = String(file.new_path || '');
216
209
  if (/[\r\n]/.test(oldPath + newPath)) throw new Error('GitLab comparison has an unsupported filename');
210
+ if (file.too_large || file.collapsed || typeof file.diff !== 'string') {
211
+ return `Binary files a/${oldPath} and b/${newPath} differ (patch omitted by provider)`;
212
+ }
217
213
  return `--- a/${oldPath}\n+++ b/${newPath}\n${file.diff}`;
218
214
  })
219
215
  .join('\n');
@@ -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 { assertAccountRepositoryUrl } from './url-security';
11
4
 
@@ -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
  export const URL_USERINFO_NOT_ALLOWED = 'Credential-bearing URLs are not allowed';
11
4