xaizek / zograscope

Mainly a syntax-aware diff that also provides a number of additional tools.
GNU Affero General Public License v3.0
51 stars 2 forks source link

Javascript support #10

Closed lgrkvst closed 3 years ago

lgrkvst commented 3 years ago

Hi, I'm on the lookout for a patch tool whose intelligence stretches beyond linenumbers, that can be run in a post-install script.

Zograscope looks interesting. Are there any plans on adding javascript support?

xaizek commented 3 years ago

Hello.

Are there any plans on adding javascript support?

I wasn't thinking about it. It's just not something I use. If tree-sitter parsers were supported, then adding JS could be easy. However, I was put off by the necessity to deal with Rust and JS to try even their C parser and haven't done it, so their trees might not even be suitable for diffing.

I'm on the lookout for a patch tool whose intelligence stretches beyond linenumbers, that can be run in a post-install script.

I don't remember seeing AST patching tools. The research papers on diffing always talk about edit scripts, but the tools usually show differences or statistics on code changes. It would probably take a combination of source (unpatched) file and a tree diff to be able to apply patches to modified files.

What are you trying to patch? Is it some kind of automatically generated file?

lgrkvst commented 3 years ago

Thanks for the swift reply.

I did some heavy alterations to a js application – little pieces of code injected here and there. Now that I'm happy with the result I'd like to apply them automatically in a build pipe every time the original js app changes.

I know there will be bugs and breaks, but I figured I have an easier life if the patch could be done with some "intelligence" as opposed to attacking mere line numbers.

Your comment lead me in a direction that winded up here: https://github.com/Vunovati/astii which might be what I need...

Keep up the good work :>

xaizek commented 3 years ago

I know there will be bugs and breaks, but I figured I have an easier life if the patch could be done with some "intelligence" as opposed to attacking mere line numbers.

Strictly speaking it's not just line numbers. I think unchanged lines (context) in unified diffs are also taken into account. You could also try automating git-rebase of your branch onto upstream's master. This will effectively "update" patches to reflect upstream changes if there are no conflicts.

Your comment lead me in a direction that winded up here: https://github.com/Vunovati/astii which might be what I need...

It's not really AST-aware, it just does source code normalization before diffing and patching, but it can help.

Keep up the good work :>

Thanks, I'll try.