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/ash
Some 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...
Solution:
You can use Igniter.do_or_dry_run
Jump to solution
8 Replies
ZachDaniel
ZachDanielโ€ข4mo ago
Check out the tools in Igniter.Project.Module for finding and creating modules w/o worrying about paths
ken-kost
ken-kostOPโ€ข4mo ago
my 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?
ZachDaniel
ZachDanielโ€ข4mo ago
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
ZachDaniel
ZachDanielโ€ข4mo ago
You can use Igniter.do_or_dry_run
ZachDaniel
ZachDanielโ€ข4mo ago
to apply any changes up til now, and then create a new igniter.
ken-kost
ken-kostOPโ€ข4mo ago
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/1295
ZachDaniel
ZachDanielโ€ข4mo ago
If 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 testing
ken-kost
ken-kostOPโ€ข4mo ago
alright, I get it, I'll setup a real flow using a project, this is not good enough. ๐Ÿ˜…

Did you find this page helpful?