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

Replace /'s for cache version dir name #258

Merged
merged 5 commits into from
Jun 18, 2019

Conversation

codedmart
Copy link
Contributor

Description of the change

TODO

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

test/SpagoSpec.hs Outdated Show resolved Hide resolved
Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small suggestion, but otherwise looks great! 👏

test/SpagoSpec.hs Outdated Show resolved Hide resolved
@codedmart
Copy link
Contributor Author

@f-f OK updated now. As per @hdgarrood's suggestion also escaping a few other characters that could be in branch names as well.

@hdgarrood
Copy link
Contributor

hdgarrood commented Jun 10, 2019

I think we should include % in the list of characters to be escaped as currently I think “%2F” and “/“ will both map to “%2F“.

Also I’ve just remembered that case insensitive file systems are a thing...

@f-f
Copy link
Member

f-f commented Jun 10, 2019

@hdgarrood agreed, this is currently still not injective but if we add % to the list it will.

And yes, e.g. my mac is case insensitive, so two branches with different cases would still clash. I think though we can just add a TODO about this and hope no one tries to fetch two branches differing only by case 😄

Btw @codedmart if you want to have some fun you could setup Quickcheck with a property that requires that getCacheVersionDir cannot map two different names to the same output (I'll merge this PR in any case, so if you want to do this feel free to open another PR. Though it's probably more interesting if you write the test before fixing the implementation, so you can marvel at Quickcheck proving things)

@codedmart
Copy link
Contributor Author

Yup forgot % and the case sensitivity. Will fix. I will look at the test as well. Thanks!

@f-f f-f mentioned this pull request Jun 11, 2019
@hdgarrood
Copy link
Contributor

hdgarrood commented Jun 11, 2019

I suppose one option is to say that any uppercase character needs escaping too; in my experience branch names rarely contain uppercase characters (so this scheme will probably give you nice readable branch names more often than not).

@hdgarrood
Copy link
Contributor

Also if you want to write a QuickCheck property for this, I think you'd need to be a bit careful if you want to end up with one that's actually useful; if you just write

quickCheck \x y -> (x /= y) ==> (getVersionCacheDir x /= getVersionCacheDir y)

then the chance of a collision is so astronomically tiny that that test is only really slowing down your test suite. I'd recommend writing your own generator which uses a much smaller set of characters to sample from, in particular including the ones we know to be problematic. Then, instead of running lots of individual tests, we should just run a single test where we generate a large set of potential branch names, apply the getVersionCacheDir function to all of them, assemble the results into another set, and check that the result set is the same size as the input set. I think this is the only way you'll get the test to fail reliably if the function is not actually injective.

@f-f
Copy link
Member

f-f commented Jun 18, 2019

@codedmart this got a bit out of sync after all the ZuriHac's contributions, so I'll merge it now so we can ship it in the upcoming release later today. Thank you! 🙂

@f-f f-f merged commit 2d30786 into purescript:master Jun 18, 2019
elliotdavies pushed a commit to elliotdavies/spago that referenced this pull request Jul 1, 2019
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

Successfully merging this pull request may close these issues.

Fails to install branches with / in the branch name
3 participants