Zipper replace and Rewrite
I'm playing around with igniter trying to figure this out. Not sure if on the right track. :thinkies:
Let's say I got to a change block and I
Sourceror.Zipper.replace
replaced the third argument with a module that I will also create.
I was thinking of doing like a git diff, which I think diff_and_yes?
function does. But I can't figure out how does this relate to rewrite/source.
I'm assuming for the task the flow will be, get to some function that can be extracted, ask for a module name, show diff that will be, confirm, next function...
The confusing part is that Rewrite expects a path, but I only got a module name. Should be going through Rewrite route to get the diff, or is there something better?
Am I even on the right track? ๐GitHub
mix ash.patch.extract_functions
ยท Issue #1295 ยท ash-project/ashSome very preliminary work for this is in the extract-functions branch. The idea here is a mix task that will interactively walk you through moving anonymous function elements in your actions to mo...
8 Replies
Check out the tools in
Igniter.Project.Module
for finding and creating modules w/o worrying about pathsmy question is more about displaying the diff of the changes made. in this case I change one block and add a new module. those changes should be displayed and user should confirm changes - correct?
to rephrase it: what tools and/or function calls could I use to display the diff?
Igniter just does that automatically
ohhh
I see what you mean
๐ค
Its not super simple ๐
Here is an idea: make your igniter task just find one and do it
to start
well...thats not important
Solution
You can use
Igniter.do_or_dry_run
to apply any changes up til now, and then create a new igniter.
I am doing it with one thing for now ๐
yea, do or die might do it ๐ค I'll try ๐
getting back to this, I made a small docs update since I have a test that I'm running my changes on. So I used
Igniter.Test.apply_igniter/1
and this returns #Igniter<rewrite: #Rewrite<6 source(s)>>
.
so I guess with that I get the rewrite in igniter and I can use that to display the diff?
I'm just curious how you imagined the interactive part flow would look and how it relates the code needed to make it happen? :thinkies:
again to clarify, I'm working on this: https://github.com/ash-project/ash/issues/1295If you use
do_or_dry_run
you can iteratively apply the igniter
You shouldn't use the testing code to apply it
It doesn't write files
It's just for testingalright, I get it, I'll setup a real flow using a project, this is not good enough. ๐