-
Notifications
You must be signed in to change notification settings - Fork 175
refactor: store diff in action object (#1693) #1701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two test gaps worth closing:
|
||
|
|
||
| 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) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: use 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 |
||
| ? data.diff | ||
| : data.steps.find((x: Step) => x.stepName === 'diff')!, | ||
| }; | ||
| return successResult(actionView); | ||
| } catch (error: unknown) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ export interface BackendResponse { | |
| } | ||
|
|
||
| export interface PushActionView extends Omit<Action, ActionMethods> { | ||
| diff: Step; | ||
| diff: Step | string; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Blocking] This introduces a TypeScript compile error:
Suggested fix: |
||
| } | ||
|
|
||
| export interface RepoView extends Repo { | ||
|
|
||
There was a problem hiding this comment.
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, stepcontent, and steplogs. All three get serialized into the audit DB on everywriteAudit(NeDB and Mongo). NeDB'sgetPusheshas 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 dropstep.setContent(diff)and the full-diffstep.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.