Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
paw-lu opened this issue Dec 29, 2021 · 1 comment

Comments

@paw-lu
Copy link

paw-lu commented Dec 29, 2021

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.

if cmd[1].startswith("-"):
# In the case of running using a profile
logger.warning(
"No .gitignore patterns will be added since a unison profile was given"
)
return False

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
Copy link
Owner

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants