Skip to content

Add uniqueness to GitCheckoutRevisionToTemporaryPath to avoid collisions when checking out the same revision from/to #58

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

Merged
merged 4 commits into from
May 2, 2018

Conversation

asgrim
Copy link
Member

@asgrim asgrim commented May 2, 2018

Fixes #53

Maybe a little over engineered, but I think this is fairly bulletproof now 😁 at least we have tests!

…ons when checking out the same revision from/to
@asgrim asgrim added the bug label May 2, 2018
@asgrim asgrim added this to the 0.0.1 milestone May 2, 2018
@asgrim asgrim requested a review from Ocramius May 2, 2018 08:18

public function __construct(?callable $uniquenessFunction = null)
{
if ($uniquenessFunction === null) {
Copy link
Member

Choose a reason for hiding this comment

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

Can simply use ?? on the assignment


if (file_exists($checkoutDirectory) || is_dir($checkoutDirectory)) {
throw new RuntimeException(sprintf(
'Tried to check out revision %s to directory %s which already exists',
Copy link
Member

Choose a reason for hiding this comment

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

Put quotes around the %s here. Also: exception type seems to be incorrect. Can we use our own please?

Copy link
Member Author

Choose a reason for hiding this comment

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

So little point in writing up a specific exception here: the chances of this happening are so slim given each directory is always unique...

Copy link
Member

Choose a reason for hiding this comment

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

Can we use an assertion then?

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find an assertion like fileNotExists or directoryNotExists etc., hence why I wrote that

Copy link
Member Author

Choose a reason for hiding this comment

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

Can do like Assert::that(file_exists($dir))->false(); or something?

@Ocramius
Copy link
Member

Ocramius commented May 2, 2018 via email

@asgrim
Copy link
Member Author

asgrim commented May 2, 2018

There's no negation thing AFAIK :s

@asgrim asgrim force-pushed the feature/prevent-path-collisions-when-cloning-repo branch from a98c462 to 5f20b6b Compare May 2, 2018 09:32
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

:shipit:

@Ocramius Ocramius merged commit cdf69ee into master May 2, 2018
@Ocramius Ocramius deleted the feature/prevent-path-collisions-when-cloning-repo branch May 2, 2018 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants