Fire preretrieve hook even when metadata is deleted (or add another hook) #2374
Replies: 5 comments
-
Thank you for filing this feature request. We appreciate your feedback and will review the feature at our next grooming or sprint planning session. We prioritize feature requests with more upvotes and comments. |
Beta Was this translation helpful? Give feedback.
-
This issue has been linked to a new work item: W-8972481 |
Beta Was this translation helpful? Give feedback.
-
I've tried this with the new source tracking commands beta #1258, and it's even more confusing. Previously with
With the new commands, it's actually more coherent: Nothing is fired. If I understand correctly, |
Beta Was this translation helpful? Give feedback.
-
Looks like it's done on purpose here. The use case of this hook, as per the documentation, is "Retrieve additional metadata or configuration when a specific source file is retrieved". I don't see why I would want to retrieve additional metadata when a file is retrieved but not when a file is deleted. Also, with the previous hook for With the new hook giving us a list of |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback and for testing the new One of the main ways it achieved that is by reduces FS operations (this is particularly a slowness cause for windows)...it generates the zip file that goes to the metadata API in memory, streaming all the converted components. So there is no One option to get what you are requesting would be to fire another preRetrieve hook from inside here with the deletes. The real problem (if I understand what you're doing with hooks) is that the old hooks let you access the "in flight" metadata and make changes to it before the deploy/retrieve, where the new ones are more "here's what's going on" but you can't change the deployment at that time because it doesn't exist locally. So you would need to do your own separate transaction outside of the one the CLI is doing. I know that's going to be bad news. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
When a metadata is deleted from the scratch org, technically nothing is retrieved via a package.xml with
sfdx force:source:pull
, and thepreretrieve
hook isn't fired.What are you trying to do
There are currently some issues with the pull command (mostly because of dependencies not being tracked on the org in
SourceMember
). For instance, when you delete a field that is referenced in a Permission Set, the field is deleted locally but the related Permission Set isn't pulled. I would like to be able to add metadata to retrieve in this hook, even if no metadata is supposed to be retrieved (but something is "pulled", like a deletion).Describe the solution you'd like
See the
preretrieve
hook firing on pull even if there are just deletions, and thus no package to retrieve so far. Also, having an additional attribute in the result type (similar to what we get withforce:source:status
with the changed metadata and state) would be a plus.Describe alternatives you've considered
I tried using the postretrieve hooks which works, but need to retrieve a second time, plus this break the source tracking (I guess there is a way to make this work).
Beta Was this translation helpful? Give feedback.
All reactions