Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/proxy/actions/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Action {
commitData?: CommitData[] = [];
commitFrom?: string;
commitTo?: string;
diff?: string;
branch?: string;
message?: string;
author?: string;
Expand Down
1 change: 1 addition & 0 deletions src/proxy/processors/push-action/getDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const exec = async (_req: Request, action: Action): Promise<Action> => {
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) {
Expand Down
7 changes: 3 additions & 4 deletions src/proxy/processors/push-action/scanDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ const exec = async (_req: Request, action: Action): Promise<Action> => {

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)
Expand Down
5 changes: 4 additions & 1 deletion src/ui/services/git-push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const getPush = async (id: string): Promise<ServiceResult<PushActionView>> => {
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface BackendResponse {
}

export interface PushActionView extends Omit<Action, ActionMethods> {
diff: Step;
diff: Step | string;
}

export interface RepoView extends Repo {
Expand Down
8 changes: 6 additions & 2 deletions src/ui/views/PushDetails/PushDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ const PushDetails = () => {
if (!push) return <div>No push data found</div>;

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';
Expand Down Expand Up @@ -456,7 +460,7 @@ const PushDetails = () => {
</Stack>
</GitProxyUnderlinePanels.Panel>
<GitProxyUnderlinePanels.Panel>
<Diff diff={push.diff?.content || ''} />
<Diff diff={diffText} />
</GitProxyUnderlinePanels.Panel>
<GitProxyUnderlinePanels.Panel>
<StepsTimeline steps={push.steps ?? []} />
Expand Down
4 changes: 4 additions & 0 deletions test/integration/forcePush.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 2 additions & 2 deletions test/processors/getDiff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down