Some .gs are ignored when pushing // Diff 'undefined'
sp-guillem-orpinell opened this issue · 6 comments
I have 4 files in a script, two of them called 'onOpen.gs' and 'onEdit.gs'. This 2 files are ignored by the assistant. Instead of finding the changes in this 2 files, it gets next changes:
I pushed the 2 files with the terminal. When pulling them from the IDE, assistant keep ignoring the existing files in the IDE and suggest me to add them as new. When accepting to add them as new, next error is thrown:
I've been using the assistant for a month, and it's a recurrent bug: ignoring some files and/or detecting diffs in an 'undefined' file.
Hi, thanks for the feedback.
Can you provide a more detailed reproduction steps?
I've tried to add two files with onOpen.gs
and onEdit.gs
in a test repo but they all seem worked as expected.
hi, does it only happened when a file is named myFunction.gs
?
i've managed to reproduce this when GAS IDE has a myFunction.gs
file already. and seems like this file does not have a name filed which the others has in the GAS RPC response.
but there is no specification about this so i'm not sure wether this is a regular behavior.
oh, i found the cause. when a .gs file contains a function which function name(eg: doSomething()
) is same as the file name(eg: doSomething.gs
), the GAS RPC's response will omit the file name field(i don't know why).
so a quickly workaround is to give the file a different name from any of the function's name.
i'll continue try to solve this but the the RPC is so weird and without any document, i'm not sure it could be fixed.
@leonhartX I think it could be helpful to identify when this issue happens, warn the user, and perhaps allow them to have the js filename to be changed automatically.
I was thinking of either using https://github.com/ariya/esprima or doing something similar to extract all of the function names in the apps script code. Then I can compare to the script file names.
If there are conflicts we can either warn the user, or just add a suffix to the script file name - I can't think of any consequences of changing the script file name?
@gulliverhan Yes, I agreed that it's better to let user knows what's going wrong.
But I think it's difficult to do the analysis work, since user could change the filename and function name anytime, if we can not provide a consistent behavior in various situation, just a warn is enough.