-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix(3235): Fetch parentEvent meta when create Event #3256
Conversation
plugins/events/create.js
Outdated
let mergedParameters = {}; | ||
|
||
payload.baseBranch = parentEvent.baseBranch || null; | ||
|
||
if (!payload.meta.parameters && parentEvent.meta && parentEvent.meta.parameters) { | ||
payload.meta.parameters = parentEvent.meta.parameters; | ||
mergedParameters = parentEvent.meta.parameters; | ||
} | ||
|
||
if (Object.keys(payload.meta).length === 0) { | ||
payload.meta = { ...parentEvent.meta }; | ||
} | ||
|
||
if (Object.keys(mergedParameters).length > 0) { | ||
payload.meta.parameters = mergedParameters; | ||
} |
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.
what about make this more simplified?
let mergedParameters = {}; | |
payload.baseBranch = parentEvent.baseBranch || null; | |
if (!payload.meta.parameters && parentEvent.meta && parentEvent.meta.parameters) { | |
payload.meta.parameters = parentEvent.meta.parameters; | |
mergedParameters = parentEvent.meta.parameters; | |
} | |
if (Object.keys(payload.meta).length === 0) { | |
payload.meta = { ...parentEvent.meta }; | |
} | |
if (Object.keys(mergedParameters).length > 0) { | |
payload.meta.parameters = mergedParameters; | |
} | |
// Merge parameters if they exist in the parent event and not in the payload | |
if (!payload.meta.parameters && parentEvent.meta && parentEvent.meta.parameters) { | |
payload.meta.parameters = parentEvent.meta.parameters; | |
} | |
// Copy meta from parent event if payload.meta is empty | |
if (Object.keys(payload.meta).length === 0) { | |
payload.meta = { ...parentEvent.meta }; | |
} |
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.
If payload(RestartedEevnt) only has parameters in meta, I think your suggested method will not fetch parentEvent meta (and neither will my method).
I will have fixed this bug.
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.
please check my suggestion
@kumada626 - can you also add couple of functional tests |
@VonnyJap Since this change does not alter normal behavior, it would be difficult to add it as a functional test. |
Context
When restart build was failed in
sd-setup-init
step and restart build from that build, meta is missing at that time.So we fix this behavior by fetching parent event meta when creating event.
Objective
Fetch parent event meta when creating event.
References
#3225
License
I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.