korekt-cli 0.9.4 → 0.9.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korekt-cli",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "AI-powered code review CLI - Keep your kode korekt",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/git-logic.js CHANGED
@@ -532,6 +532,7 @@ export async function runLocalReview(targetBranch = null, ignorePatterns = null)
532
532
  commit_messages: commitMessages,
533
533
  changed_files: changedFiles,
534
534
  source_branch: branchName,
535
+ destination_branch: targetBranch,
535
536
  author_email,
536
537
  author_name,
537
538
  contributors,
@@ -1013,6 +1013,109 @@ describe('is_ci flag in payload', () => {
1013
1013
  });
1014
1014
  });
1015
1015
 
1016
+ describe('destination_branch in payload', () => {
1017
+ beforeEach(() => {
1018
+ vi.mock('execa');
1019
+ vi.mock('./utils.js', () => ({
1020
+ detectCIProvider: vi.fn().mockReturnValue(null),
1021
+ getPrUrl: vi.fn().mockReturnValue(null),
1022
+ getSourceBranchFromCI: vi.fn().mockReturnValue(null),
1023
+ }));
1024
+ });
1025
+
1026
+ afterEach(() => {
1027
+ vi.restoreAllMocks();
1028
+ });
1029
+
1030
+ it('should include destination_branch when target branch is specified', async () => {
1031
+ vi.mocked(execa).mockImplementation(async (cmd, args) => {
1032
+ const command = [cmd, ...args].join(' ');
1033
+
1034
+ if (command.includes('remote get-url origin')) {
1035
+ return { stdout: 'https://github.com/user/repo.git' };
1036
+ }
1037
+ if (command.includes('rev-parse --abbrev-ref HEAD')) {
1038
+ return { stdout: 'feature-branch' };
1039
+ }
1040
+ if (command.includes('rev-parse --show-toplevel')) {
1041
+ return { stdout: '/path/to/repo' };
1042
+ }
1043
+ if (command.includes('rev-parse --verify main')) {
1044
+ return { stdout: 'commit-hash' };
1045
+ }
1046
+ if (command === 'git fetch origin main') {
1047
+ return { stdout: '' };
1048
+ }
1049
+ if (command.includes('merge-base origin/main HEAD')) {
1050
+ return { stdout: 'abc123' };
1051
+ }
1052
+ if (command.includes('log --no-merges --pretty=%B---EOC---')) {
1053
+ return { stdout: 'feat: add feature---EOC---' };
1054
+ }
1055
+ if (command.includes('log --no-merges --format=%ae|%an')) {
1056
+ return { stdout: 'user@example.com|User Name' };
1057
+ }
1058
+ if (command.includes('diff --name-status')) {
1059
+ return { stdout: 'M\tfile.js' };
1060
+ }
1061
+ if (command.includes('diff -U15')) {
1062
+ return { stdout: 'diff content' };
1063
+ }
1064
+ if (command.includes('show abc123:file.js')) {
1065
+ return { stdout: 'original content' };
1066
+ }
1067
+
1068
+ return { stdout: '' };
1069
+ });
1070
+
1071
+ const result = await runLocalReview('main');
1072
+
1073
+ expect(result).toBeDefined();
1074
+ expect(result.destination_branch).toBe('main');
1075
+ });
1076
+
1077
+ it('should have null destination_branch when no target branch specified', async () => {
1078
+ vi.mocked(execa).mockImplementation(async (cmd, args) => {
1079
+ const command = [cmd, ...args].join(' ');
1080
+
1081
+ if (command.includes('remote get-url origin')) {
1082
+ return { stdout: 'https://github.com/user/repo.git' };
1083
+ }
1084
+ if (command.includes('rev-parse --abbrev-ref HEAD')) {
1085
+ return { stdout: 'feature-branch' };
1086
+ }
1087
+ if (command.includes('rev-parse --show-toplevel')) {
1088
+ return { stdout: '/path/to/repo' };
1089
+ }
1090
+ if (command.includes('reflog show --no-abbrev-commit')) {
1091
+ return {
1092
+ stdout:
1093
+ '510572bc5197788770004d0d0585822adab0128f checkout: moving from main to feature-branch',
1094
+ };
1095
+ }
1096
+ if (command.includes('log --no-merges --pretty=%B---EOC---')) {
1097
+ return { stdout: 'feat: add feature---EOC---' };
1098
+ }
1099
+ if (command.includes('diff --name-status')) {
1100
+ return { stdout: 'M\tfile.js' };
1101
+ }
1102
+ if (command.includes('diff -U15')) {
1103
+ return { stdout: 'diff content' };
1104
+ }
1105
+ if (command.includes('show 510572bc5197788770004d0d0585822adab0128f:file.js')) {
1106
+ return { stdout: 'original content' };
1107
+ }
1108
+
1109
+ return { stdout: '' };
1110
+ });
1111
+
1112
+ const result = await runLocalReview(); // No target branch
1113
+
1114
+ expect(result).toBeDefined();
1115
+ expect(result.destination_branch).toBeNull();
1116
+ });
1117
+ });
1118
+
1016
1119
  describe('getSourceBranchFromCI', () => {
1017
1120
  const originalEnv = process.env;
1018
1121