plugin-git-manager 1.2.27 → 1.2.28
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/README.md +133 -108
- package/client-v2.d.ts +2 -2
- package/client-v2.js +1 -1
- package/client.d.ts +3 -3
- package/client.js +1 -1
- package/dist/client/{326.90c276058682b536.js → 313.d38fc1d40c4589b9.js} +1 -1
- package/dist/client/900.a48beac7e2ebee7d.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/156.445366026c1cc9a8.js +10 -0
- package/dist/client-v2/{326.42b7b53651ffab3a.js → 313.3c867179c3a1e817.js} +1 -1
- package/dist/client-v2/434.19c7579c06b9077c.js +10 -0
- package/dist/client-v2/900.e6155002a9c97e7f.js +10 -0
- package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +307 -297
- package/dist/locale/vi-VN.json +295 -292
- package/dist/locale/zh-CN.json +61 -51
- package/dist/node_modules/simple-git/dist/cjs/index.js +25 -25
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/git-actions.js +90 -36
- package/dist/server/actions/gitlab-api.js +4 -2
- package/dist/server/actions/poller.js +5 -2
- package/dist/server/actions/review.js +20 -10
- package/dist/server/plugin.js +6 -4
- package/dist/server/poller.js +46 -45
- package/dist/server/request-method-policy.js +75 -0
- package/dist/server/services/registry-content-service.js +4 -3
- package/dist/server/utils/get-repo-account.js +3 -2
- package/dist/server/utils/url-security.js +24 -0
- package/package.json +61 -43
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/client/__tests__/RunReviewButton.test.tsx +73 -0
- package/src/client/ai-context.tsx +114 -114
- package/src/client/components/AIEmployeeSelect.tsx +63 -63
- package/src/client/components/CommitHistory.tsx +374 -374
- package/src/client/components/FileExplorer.tsx +386 -386
- package/src/client/components/GitAccounts.tsx +179 -179
- package/src/client/components/GitManagerSettings.tsx +160 -160
- package/src/client/components/GitOperations.tsx +220 -220
- package/src/client/components/LLMModelSelect.tsx +63 -63
- package/src/client/components/LLMServiceSelect.tsx +58 -58
- package/src/client/components/MarkdownView.tsx +80 -80
- package/src/client/components/MergeRequests.tsx +790 -790
- package/src/client/components/PollingStatus.tsx +225 -225
- package/src/client/components/RepositoryConfig.tsx +335 -335
- package/src/client/components/RepositoryPermissions.tsx +123 -123
- package/src/client/components/ReviewFlows.tsx +303 -303
- package/src/client/components/ReviewHistory.tsx +566 -566
- package/src/client/components/RunReviewButton.tsx +63 -55
- package/src/client/context/GitManagerContext.tsx +92 -92
- package/src/client/index.tsx +91 -82
- package/src/client/locale.ts +9 -9
- package/src/client/promptTemplates.ts +31 -31
- package/src/client-v2/ai-context.tsx +99 -0
- package/src/client-v2/components/SubtreeSplits.tsx +547 -547
- package/src/client-v2/index.tsx +1 -1
- package/src/client-v2/locale.ts +8 -8
- package/src/client-v2/plugin.tsx +67 -39
- package/src/index.ts +2 -2
- package/src/locale/en-US.json +307 -297
- package/src/locale/vi-VN.json +295 -292
- package/src/locale/zh-CN.json +61 -51
- package/src/server/__tests__/git-actions.test.ts +24 -24
- package/src/server/__tests__/git-security.test.ts +170 -0
- package/src/server/__tests__/plugin-url-security.test.ts +17 -17
- package/src/server/__tests__/poller-lifecycle.test.ts +71 -0
- package/src/server/__tests__/poller.test.ts +37 -37
- package/src/server/__tests__/repository-access.test.ts +752 -752
- package/src/server/__tests__/review.test.ts +137 -137
- package/src/server/__tests__/role-permissions.test.ts +147 -147
- package/src/server/__tests__/smoke.test.ts +139 -17
- package/src/server/__tests__/subtree.test.ts +85 -85
- package/src/server/actions/git-actions.ts +540 -480
- package/src/server/actions/gitlab-api.ts +422 -411
- package/src/server/actions/poller.ts +39 -27
- package/src/server/actions/review.ts +1388 -1369
- package/src/server/actions/role-permissions.ts +321 -321
- package/src/server/actions/subtree.ts +508 -508
- package/src/server/ai-tools.ts +319 -319
- package/src/server/collections/gitAccounts.ts +56 -56
- package/src/server/collections/gitCodeReviews.ts +199 -199
- package/src/server/collections/gitRepositories.ts +87 -87
- package/src/server/collections/gitReviewFlows.ts +108 -108
- package/src/server/collections/gitSubtreeConfigs.ts +38 -38
- package/src/server/collections/gitSubtreeRuns.ts +30 -30
- package/src/server/index.ts +2 -2
- package/src/server/migrations/20260508000000-add-auto-review-flow-id.ts +29 -29
- package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -198
- package/src/server/migrations/20260730000000-migrate-legacy-repository-permissions.ts +81 -81
- package/src/server/plugin.ts +372 -361
- package/src/server/poller.ts +351 -352
- package/src/server/repository-access.ts +773 -773
- package/src/server/request-method-policy.ts +55 -0
- package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
- package/src/server/services/registry-content-service.ts +495 -484
- package/src/server/utils/__tests__/redact.test.ts +56 -56
- package/src/server/utils/__tests__/url-security.test.ts +85 -85
- package/src/server/utils/get-repo-account.ts +51 -41
- package/src/server/utils/gitlab-url.ts +38 -38
- package/src/server/utils/redact.ts +87 -87
- package/src/server/utils/url-security.ts +128 -95
- package/dist/client/900.acf7d1fa22f95e71.js +0 -10
- package/dist/client-v2/434.7a27051db18526c0.js +0 -10
- package/dist/client-v2/900.f32b9dc85249fc0a.js +0 -10
|
@@ -1,17 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync } from 'child_process';
|
|
11
|
+
import { mkdtempSync, mkdirSync, rmSync, symlinkSync, unlinkSync } from 'fs';
|
|
12
|
+
import { tmpdir } from 'os';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
import { createMockServer, type MockServer } from '@nocobase/test';
|
|
15
|
+
import PluginGitManagerServer from '../plugin';
|
|
16
|
+
|
|
17
|
+
describe('Git Manager HTTP integration', () => {
|
|
18
|
+
let app: MockServer;
|
|
19
|
+
let agent: ReturnType<MockServer['agent']>;
|
|
20
|
+
let fixture: string;
|
|
21
|
+
let repoPath: string;
|
|
22
|
+
let repositoryId: number;
|
|
23
|
+
const originalBase = process.env.GIT_REPOS_BASE_PATH;
|
|
24
|
+
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
fixture = mkdtempSync(join(tmpdir(), 'git-manager-http-'));
|
|
27
|
+
repoPath = join(fixture, 'repository');
|
|
28
|
+
mkdirSync(repoPath);
|
|
29
|
+
process.env.GIT_REPOS_BASE_PATH = fixture;
|
|
30
|
+
execFileSync('git', ['init', '-b', 'main', repoPath], { stdio: 'ignore' });
|
|
31
|
+
execFileSync(
|
|
32
|
+
'git',
|
|
33
|
+
[
|
|
34
|
+
'-C',
|
|
35
|
+
repoPath,
|
|
36
|
+
'-c',
|
|
37
|
+
'user.name=Test',
|
|
38
|
+
'-c',
|
|
39
|
+
'user.email=test@example.invalid',
|
|
40
|
+
'commit',
|
|
41
|
+
'--allow-empty',
|
|
42
|
+
'-m',
|
|
43
|
+
'fixture',
|
|
44
|
+
],
|
|
45
|
+
{ stdio: 'ignore' },
|
|
46
|
+
);
|
|
47
|
+
execFileSync('git', ['-C', repoPath, 'branch', 'marker'], { stdio: 'ignore' });
|
|
48
|
+
app = await createMockServer({
|
|
49
|
+
acl: true,
|
|
50
|
+
registerActions: true,
|
|
51
|
+
plugins: [
|
|
52
|
+
'field-sort',
|
|
53
|
+
'system-settings',
|
|
54
|
+
'users',
|
|
55
|
+
'auth',
|
|
56
|
+
'acl',
|
|
57
|
+
'data-source-manager',
|
|
58
|
+
'data-source-main',
|
|
59
|
+
'error-handler',
|
|
60
|
+
[PluginGitManagerServer, { name: 'plugin-git-manager' }],
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
const repository = await app.db.getRepository('gitRepositories').create({
|
|
64
|
+
values: { name: 'fixture', localPath: 'repository', repoUrl: 'https://gitlab.com/team/fixture.git' },
|
|
65
|
+
});
|
|
66
|
+
repositoryId = repository.get('id');
|
|
67
|
+
agent = await app.agent().login(await app.db.getRepository('users').findOne());
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
afterAll(async () => {
|
|
71
|
+
await app?.destroy();
|
|
72
|
+
if (originalBase === undefined) delete process.env.GIT_REPOS_BASE_PATH;
|
|
73
|
+
else process.env.GIT_REPOS_BASE_PATH = originalBase;
|
|
74
|
+
if (fixture) rmSync(fixture, { recursive: true, force: true });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('loads the actual plugin, collection and resource handler', async () => {
|
|
78
|
+
expect(app.pm.get('plugin-git-manager')).toBeInstanceOf(PluginGitManagerServer);
|
|
79
|
+
expect(app.db.getCollection('gitRepositories')).toBeTruthy();
|
|
80
|
+
const response = await agent.get('/gitManager:pollerStatus');
|
|
81
|
+
expect(response.status).toBe(200);
|
|
82
|
+
expect(response.body.data).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it.each([
|
|
86
|
+
'clone',
|
|
87
|
+
'pull',
|
|
88
|
+
'push',
|
|
89
|
+
'fetch',
|
|
90
|
+
'checkout',
|
|
91
|
+
'triggerReview',
|
|
92
|
+
'reviewApprovePost',
|
|
93
|
+
'reviewReject',
|
|
94
|
+
'pollNow',
|
|
95
|
+
'updateRolePermissions',
|
|
96
|
+
'subtreePreview',
|
|
97
|
+
'subtreeOptions',
|
|
98
|
+
'subtreeRun',
|
|
99
|
+
'subtreeReplace',
|
|
100
|
+
])('rejects GET on %s before executing it', async (action) => {
|
|
101
|
+
const response = await agent.get(`/gitManager:${action}`).query({ repositoryId, branch: 'marker' });
|
|
102
|
+
expect(response.status).toBe(405);
|
|
103
|
+
expect(response.headers.allow).toBe('POST');
|
|
104
|
+
expect(execFileSync('git', ['-C', repoPath, 'branch', '--show-current'], { encoding: 'utf8' }).trim()).toBe('main');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('rejects a junction escaping the configured root through the real POST handler', async () => {
|
|
108
|
+
const confinedBase = join(fixture, 'confined');
|
|
109
|
+
mkdirSync(confinedBase);
|
|
110
|
+
const alias = join(confinedBase, 'alias');
|
|
111
|
+
symlinkSync(repoPath, alias, 'junction');
|
|
112
|
+
process.env.GIT_REPOS_BASE_PATH = confinedBase;
|
|
113
|
+
try {
|
|
114
|
+
const escaped = await app.db.getRepository('gitRepositories').create({
|
|
115
|
+
values: { name: 'escaped', localPath: 'alias', repoUrl: 'https://gitlab.com/team/fixture.git' },
|
|
116
|
+
});
|
|
117
|
+
const response = await agent
|
|
118
|
+
.post('/gitManager:checkout')
|
|
119
|
+
.send({ repositoryId: escaped.get('id'), branch: 'marker' });
|
|
120
|
+
expect(response.status).toBe(400);
|
|
121
|
+
expect(execFileSync('git', ['-C', repoPath, 'branch', '--show-current'], { encoding: 'utf8' }).trim()).toBe(
|
|
122
|
+
'main',
|
|
123
|
+
);
|
|
124
|
+
} finally {
|
|
125
|
+
process.env.GIT_REPOS_BASE_PATH = fixture;
|
|
126
|
+
unlinkSync(alias);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('rejects HEAD and still allows authorized POST checkout', async () => {
|
|
131
|
+
const head = await agent.head('/gitManager:checkout').query({ repositoryId, branch: 'marker' });
|
|
132
|
+
expect(head.status).toBe(405);
|
|
133
|
+
const post = await agent.post('/gitManager:checkout').send({ repositoryId, branch: 'marker' });
|
|
134
|
+
expect(post.status).toBe(200);
|
|
135
|
+
expect(execFileSync('git', ['-C', repoPath, 'branch', '--show-current'], { encoding: 'utf8' }).trim()).toBe(
|
|
136
|
+
'marker',
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
SUBTREE_EXECUTION_MODE,
|
|
4
|
-
validateRemoteName,
|
|
5
|
-
validateRunAgainstPreview,
|
|
6
|
-
validateSubtreeConfigInput,
|
|
7
|
-
validateSubtreePolicy,
|
|
8
|
-
validateSubtreePrefix,
|
|
9
|
-
validateSubtreePrefixes,
|
|
10
|
-
} from '../actions/subtree';
|
|
11
|
-
|
|
12
|
-
describe('Git subtree validation', () => {
|
|
13
|
-
it('accepts and normalizes one relative source folder', () => {
|
|
14
|
-
expect(validateSubtreePrefix('./apps/admin/')).toBe('apps/admin');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it.each(['../admin', 'apps/../admin', '/apps/admin', 'C:/apps/admin', ''])('rejects unsafe prefix %s', (prefix) => {
|
|
18
|
-
expect(() => validateSubtreePrefix(prefix)).toThrow();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('accepts, normalizes, de-duplicates, and sorts multiple source folders', () => {
|
|
22
|
-
expect(validateSubtreePrefixes(['./packages/plugin-b/', 'packages/plugin-a', 'packages/plugin-b'])).toEqual([
|
|
23
|
-
'packages/plugin-a',
|
|
24
|
-
'packages/plugin-b',
|
|
25
|
-
]);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('rejects overlapping parent and child source folders', () => {
|
|
29
|
-
expect(() => validateSubtreePrefixes(['packages', 'packages/plugin-a'])).toThrow('overlapping');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('requires different source and target branches', () => {
|
|
33
|
-
expect(() =>
|
|
34
|
-
validateSubtreeConfigInput({
|
|
35
|
-
sourceBranch: 'main',
|
|
36
|
-
targetBranch: 'main',
|
|
37
|
-
sourcePrefix: 'apps/admin',
|
|
38
|
-
remoteName: 'origin',
|
|
39
|
-
defaultPolicy: 'fastForward',
|
|
40
|
-
}),
|
|
41
|
-
).toThrow('Source branch and target branch must be different');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it.each(['fastForward', 'replace', 'merge'])('accepts the %s policy', (policy) => {
|
|
45
|
-
expect(validateSubtreePolicy(policy)).toBe(policy);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('rejects option injection in the remote name', () => {
|
|
49
|
-
expect(() => validateRemoteName('--upload-pack=evil')).toThrow('Invalid Git remote name');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it.each(['feature..bad', 'feature.lock', '.hidden', 'feature//bad'])('rejects invalid Git branch %s', (branch) => {
|
|
53
|
-
expect(() =>
|
|
54
|
-
validateSubtreeConfigInput({ sourceBranch: branch, targetBranch: 'deploy', sourcePrefix: 'apps/admin' }),
|
|
55
|
-
).toThrow('Invalid branch name');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('Git subtree update policy', () => {
|
|
60
|
-
it('runs interactively on the app process instead of the review queue', () => {
|
|
61
|
-
expect(SUBTREE_EXECUTION_MODE).toBe('app');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('blocks fast-forward when the target has diverged', () => {
|
|
65
|
-
expect(() => validateRunAgainstPreview('fastForward', { relationship: 'diverged', targetSha: 'old' })).toThrow(
|
|
66
|
-
'Target branch cannot be fast-forwarded',
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('requires the exact preview SHA before replacing an existing target', () => {
|
|
71
|
-
expect(() => validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' })).toThrow(
|
|
72
|
-
'requires the preview target SHA',
|
|
73
|
-
);
|
|
74
|
-
expect(() =>
|
|
75
|
-
validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' }, 'changed'),
|
|
76
|
-
).toThrow('Target branch changed after preview');
|
|
77
|
-
expect(() =>
|
|
78
|
-
validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' }, 'old'),
|
|
79
|
-
).not.toThrow();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('allows merge for unrelated or diverged histories', () => {
|
|
83
|
-
expect(() => validateRunAgainstPreview('merge', { relationship: 'diverged', targetSha: 'old' })).not.toThrow();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
SUBTREE_EXECUTION_MODE,
|
|
4
|
+
validateRemoteName,
|
|
5
|
+
validateRunAgainstPreview,
|
|
6
|
+
validateSubtreeConfigInput,
|
|
7
|
+
validateSubtreePolicy,
|
|
8
|
+
validateSubtreePrefix,
|
|
9
|
+
validateSubtreePrefixes,
|
|
10
|
+
} from '../actions/subtree';
|
|
11
|
+
|
|
12
|
+
describe('Git subtree validation', () => {
|
|
13
|
+
it('accepts and normalizes one relative source folder', () => {
|
|
14
|
+
expect(validateSubtreePrefix('./apps/admin/')).toBe('apps/admin');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it.each(['../admin', 'apps/../admin', '/apps/admin', 'C:/apps/admin', ''])('rejects unsafe prefix %s', (prefix) => {
|
|
18
|
+
expect(() => validateSubtreePrefix(prefix)).toThrow();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('accepts, normalizes, de-duplicates, and sorts multiple source folders', () => {
|
|
22
|
+
expect(validateSubtreePrefixes(['./packages/plugin-b/', 'packages/plugin-a', 'packages/plugin-b'])).toEqual([
|
|
23
|
+
'packages/plugin-a',
|
|
24
|
+
'packages/plugin-b',
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('rejects overlapping parent and child source folders', () => {
|
|
29
|
+
expect(() => validateSubtreePrefixes(['packages', 'packages/plugin-a'])).toThrow('overlapping');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('requires different source and target branches', () => {
|
|
33
|
+
expect(() =>
|
|
34
|
+
validateSubtreeConfigInput({
|
|
35
|
+
sourceBranch: 'main',
|
|
36
|
+
targetBranch: 'main',
|
|
37
|
+
sourcePrefix: 'apps/admin',
|
|
38
|
+
remoteName: 'origin',
|
|
39
|
+
defaultPolicy: 'fastForward',
|
|
40
|
+
}),
|
|
41
|
+
).toThrow('Source branch and target branch must be different');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it.each(['fastForward', 'replace', 'merge'])('accepts the %s policy', (policy) => {
|
|
45
|
+
expect(validateSubtreePolicy(policy)).toBe(policy);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('rejects option injection in the remote name', () => {
|
|
49
|
+
expect(() => validateRemoteName('--upload-pack=evil')).toThrow('Invalid Git remote name');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.each(['feature..bad', 'feature.lock', '.hidden', 'feature//bad'])('rejects invalid Git branch %s', (branch) => {
|
|
53
|
+
expect(() =>
|
|
54
|
+
validateSubtreeConfigInput({ sourceBranch: branch, targetBranch: 'deploy', sourcePrefix: 'apps/admin' }),
|
|
55
|
+
).toThrow('Invalid branch name');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('Git subtree update policy', () => {
|
|
60
|
+
it('runs interactively on the app process instead of the review queue', () => {
|
|
61
|
+
expect(SUBTREE_EXECUTION_MODE).toBe('app');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('blocks fast-forward when the target has diverged', () => {
|
|
65
|
+
expect(() => validateRunAgainstPreview('fastForward', { relationship: 'diverged', targetSha: 'old' })).toThrow(
|
|
66
|
+
'Target branch cannot be fast-forwarded',
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('requires the exact preview SHA before replacing an existing target', () => {
|
|
71
|
+
expect(() => validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' })).toThrow(
|
|
72
|
+
'requires the preview target SHA',
|
|
73
|
+
);
|
|
74
|
+
expect(() =>
|
|
75
|
+
validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' }, 'changed'),
|
|
76
|
+
).toThrow('Target branch changed after preview');
|
|
77
|
+
expect(() =>
|
|
78
|
+
validateRunAgainstPreview('replace', { relationship: 'diverged', targetSha: 'old' }, 'old'),
|
|
79
|
+
).not.toThrow();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('allows merge for unrelated or diverged histories', () => {
|
|
83
|
+
expect(() => validateRunAgainstPreview('merge', { relationship: 'diverged', targetSha: 'old' })).not.toThrow();
|
|
84
|
+
});
|
|
85
|
+
});
|