lime-green / unison-gitignore

A gitignore-aware wrapper around Unison
MIT License
9 stars 1 forks source link

False positive on detecting profile usage when options are provided before root arguments #9

Open paw-lu opened 2 years ago

paw-lu commented 2 years ago

I'm pretty new to Unison, so this might be a misunderstaning on my part! If I understand the following section correcly, it seems that unison-gitignore will mistakingly detect profile usage if any option is provided before the main arguments.

https://github.com/lime-green/unison-gitignore/blob/3ea8e702fe310f47cf2830c9c33ddca7abfff5a5/src/unison_gitignore/util.py#L56-L61

For example:

# Here we call -auto before the root arguments, and .gitignore patterns are not added
% unison-gitignore -auto root1 root2
unison_gitignore :: WARNING  :: No .gitignore patterns will be added since a unison profile was given

# Now we move -auto to after the root arguments, and everything works as expected
% unison-gitignore dir1 dir2 -auto

Again, new to unison, but the usage docs state:

Usage: unison [options]
    or unison root1 root2 [options]
    or unison profilename [options]

So would detecting if cmd[1].startswith("-") even detect profilename—or is that not the point?


Also thanks for sharing the great tool, it's been incredibly useful to me!

lime-green commented 1 year ago

@paw-lu hey sorry this is so late! cmd at this point will not contain the first argument (https://github.com/lime-green/unison-gitignore/blob/master/src/unison_gitignore/main.py#L20-L22) so in your example it should contain ["-auto", "root1", "root2"] and hence not detect profile usage. I think what I had in mind with this is that the usage of unison profilename [options] I could detect if seeing if the second argument is an option and hence assume profile is being used. It's weird that unison-gitignore -auto root1 root2 is showing that error message for you though, since that's not how the code should work and I can't reproduce it with using that command