diff --git a/package-lock.json b/package-lock.json index 7995b6bdd..34349d149 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2217,18 +2217,6 @@ "react-dom": "^16.8.0 || ^17.0.0" } }, - "node_modules/@finos/git-proxy/node_modules/@types/react": { - "version": "17.0.93", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.93.tgz", - "integrity": "sha512-KM4Ty/ZTLZupiYxZVAlP+InNJS3De6uBMdq0ePa6/04+eG9Y7ftnWfst1xTLQ5rwAhgHwQ4momt/O4KepdGBTw==", - "extraneous": true, - "license": "MIT", - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "^0.16", - "csstype": "^3.2.2" - } - }, "node_modules/@finos/git-proxy/node_modules/dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", @@ -4413,13 +4401,6 @@ "@types/passport": "*" } }, - "node_modules/@types/prop-types": { - "version": "15.7.15", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", - "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", - "extraneous": true, - "license": "MIT" - }, "node_modules/@types/qs": { "version": "6.15.1", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.1.tgz", @@ -4462,13 +4443,6 @@ "@types/react": "*" } }, - "node_modules/@types/scheduler": { - "version": "0.16.8", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", - "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", - "extraneous": true, - "license": "MIT" - }, "node_modules/@types/send": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", @@ -15841,20 +15815,6 @@ } } }, - "node_modules/vite-tsconfig-paths/node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "extraneous": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/vite/node_modules/lightningcss": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", diff --git a/src/proxy/actions/Action.ts b/src/proxy/actions/Action.ts index 66dc172b1..2766e9df9 100644 --- a/src/proxy/actions/Action.ts +++ b/src/proxy/actions/Action.ts @@ -62,6 +62,7 @@ class Action { commitData?: CommitData[] = []; commitFrom?: string; commitTo?: string; + diff?: string; branch?: string; message?: string; author?: string; diff --git a/src/proxy/processors/push-action/getDiff.ts b/src/proxy/processors/push-action/getDiff.ts index 445b119e4..723405291 100644 --- a/src/proxy/processors/push-action/getDiff.ts +++ b/src/proxy/processors/push-action/getDiff.ts @@ -49,6 +49,7 @@ const exec = async (_req: Request, action: Action): Promise => { step.log(`Executing "git diff ${commitFrom} ${action.commitTo}" in ${path}`); const revisionRange = `${commitFrom}..${action.commitTo}`; const diff = await git.diff([revisionRange]); + action.diff = diff; step.log(diff); step.setContent(diff); } catch (error: unknown) { diff --git a/src/proxy/processors/push-action/scanDiff.ts b/src/proxy/processors/push-action/scanDiff.ts index a9cfa5d78..9410c9b53 100644 --- a/src/proxy/processors/push-action/scanDiff.ts +++ b/src/proxy/processors/push-action/scanDiff.ts @@ -179,11 +179,10 @@ const exec = async (_req: Request, action: Action): Promise => { const { steps, commitFrom, commitTo } = action; step.log(`Scanning diff: ${commitFrom}:${commitTo}`); + const diff = action.diff ?? steps.find((s) => s.stepName === 'diff')?.content; - const diff = steps.find((s) => s.stepName === 'diff')?.content; - - step.log(diff); - const diffViolations = getDiffViolations(diff, action.project, step); + step.log(diff as string); + const diffViolations = getDiffViolations(diff as string, action.project, step); if (diffViolations) { const formattedMatches = Array.isArray(diffViolations) diff --git a/src/ui/services/git-push.ts b/src/ui/services/git-push.ts index f2522ccf2..b72d30eae 100644 --- a/src/ui/services/git-push.ts +++ b/src/ui/services/git-push.ts @@ -30,7 +30,10 @@ const getPush = async (id: string): Promise> => { const data: Action = response.data; const actionView: PushActionView = { ...data, - diff: data.steps.find((x: Step) => x.stepName === 'diff')!, + diff: + typeof data.diff == 'string' + ? data.diff + : data.steps.find((x: Step) => x.stepName === 'diff')!, }; return successResult(actionView); } catch (error: unknown) { diff --git a/src/ui/types.ts b/src/ui/types.ts index 8d125221a..b9afffa5b 100644 --- a/src/ui/types.ts +++ b/src/ui/types.ts @@ -54,7 +54,7 @@ export interface BackendResponse { } export interface PushActionView extends Omit { - diff: Step; + diff: Step | string; } export interface RepoView extends Repo { diff --git a/src/ui/views/PushDetails/PushDetails.tsx b/src/ui/views/PushDetails/PushDetails.tsx index f54ed0dee..2936bae60 100644 --- a/src/ui/views/PushDetails/PushDetails.tsx +++ b/src/ui/views/PushDetails/PushDetails.tsx @@ -232,7 +232,11 @@ const PushDetails = () => { if (!push) return
No push data found
; const commitCount = push.commitData?.length ?? 0; - const changeFileCount = countDiffFiles(push.diff?.content ?? ''); + const diffText = + typeof push.diff === 'string' + ? push.diff + : (push.diff?.content ?? push.steps?.find((s) => s.stepName === 'diff')?.content ?? ''); + const changeFileCount = countDiffFiles(diffText); const stepCount = push.steps?.length ?? 0; let statusTitle: PushStatusTitle = 'Pending'; @@ -456,7 +460,7 @@ const PushDetails = () => { - + diff --git a/test/integration/forcePush.integration.test.ts b/test/integration/forcePush.integration.test.ts index 50e520b60..ed8bba07c 100644 --- a/test/integration/forcePush.integration.test.ts +++ b/test/integration/forcePush.integration.test.ts @@ -116,6 +116,10 @@ describe('Force Push Integration Test', () => { expect(typeof diffStep.content).toBe('string'); expect(diffStep.content.length).toBeGreaterThan(0); + expect(typeof afterGetDiff.diff).toBe('string'); + expect((afterGetDiff.diff as string).length).toBeGreaterThan(0); + expect(afterGetDiff.diff).toEqual(diffStep.content); + const afterScanDiff = await scanDiff(req, afterGetDiff); const scanStep = afterScanDiff.steps.find((s: Step) => s.stepName === 'scanDiff'); diff --git a/test/processors/getDiff.test.ts b/test/processors/getDiff.test.ts index af2f4eb4a..507435c0a 100644 --- a/test/processors/getDiff.test.ts +++ b/test/processors/getDiff.test.ts @@ -73,8 +73,8 @@ describe('getDiff', () => { const result = await exec({} as Request, action); expect(result.steps[0].error).toBe(false); - expect(result.steps[0].content).toContain('modified content'); - expect(result.steps[0].content).toContain('initial content'); + expect(result.diff).toContain('modified content'); + expect(result.diff).toContain('initial content'); }); it('should get diff between commits with no changes', async () => {