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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is now persisted in three places per push: action.diff, step content, and step logs. All three get serialized into the audit DB on every writeAudit (NeDB and Mongo). NeDB's getPushes has no projection, so the pushes-list payload also grows by another full-diff copy per push.

Now that all consumers read action.diff (the legacy fallback is only needed for old records), could we drop step.setContent(diff) and the full-diff step.log(diff) here and keep just a summary (e.g. diff size)? If you'd rather keep this PR minimal, let's at least note the extra storage copy in the description and track the cleanup as a follow-up.

} 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two test gaps worth closing:

  1. Precedence is untested. If action.diff and the diff step content ever diverge, this silently prefers action.diff. A test pinning that precedence would lock the semantics in (the legacy fallback itself is already covered by the existing scanDiff tests).
  2. getPush in test/ui/git-push.test.ts is only mocked with the legacy step shape, so the new typeof data.diff == 'string' branch has no coverage. A test with a top-level string diff (including the empty-string case, which should still win over the fallback) would help.


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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use === over == to match codebase style.

One more expectation to manage: the plugin benefit from #1693 won't materialize from this change alone. Plugins are prepended to the chain, so they run before getDiff and can't read action.diff in the same pass. Real plugin access needs post-diff plugin positioning (part of the #1683 revamp scope). Worth softening that point in the PR description.

? 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blocking] This introduces a TypeScript compile error:

src/ui/types.ts(56,18): error TS2430: Interface 'PushActionView' incorrectly extends interface 'Omit<Action, ActionMethods>'.
  Types of property 'diff' are incompatible.
    Type 'string | Step' is not assignable to type 'string | undefined'.
      Type 'Step' is not assignable to type 'string'.

Action.diff added in this PR is string | undefined, so this declaration no longer satisfies the base interface. Current PR CI doesn't run check-types, so it slips through, but it breaks npm run check-types and every contributor's IDE.

Suggested fix: diff: string | Step | undefined;. That is also more honest, since records without a diff step (e.g. tag pushes) are already undefined at runtime today.

}

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