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

Bump nikolaposa/version version #61

Closed
wants to merge 1 commit into from

Conversation

ntzm
Copy link
Contributor

@ntzm ntzm commented May 4, 2018

Partially fixes #37, allows for v prefix but not release-

PHPStan is failing due to the return type for VersionsCollection::getIterator is Traversable, which doesn't have the current method. Not sure what the best fix is here?

Tests and code for checking if a VersionsCollection is empty have been removed, due to VersionsCollection requiring at least one Version in the constructor.

@ntzm ntzm force-pushed the bump-version-version branch from 05247e3 to 3694052 Compare May 4, 2018 19:54
@@ -30,7 +30,7 @@ public function fromRepository(CheckedOutRepository $checkedOutRepository) : Ver
->mustRun()
->getOutput();

return VersionsCollection::fromArray(array_filter(
return new VersionsCollection(...array_filter(
Copy link
Member

Choose a reason for hiding this comment

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

An array_values() is needed here. To test this, try an array of [1.0.0, 1.potato, 2.0.0] and you will get a TypeError if I remember correctly (test is to be added)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems OK to me: https://3v4l.org/d5RvE

We test invalid at testFromRepositoryIgnoresInvalidVersions

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, interesting. I guess it crashes only when there are non-numeric keys then 👍

@@ -19,8 +18,6 @@
*/
public function forVersions(VersionsCollection $versions) : Version
{
Assert::that($versions->count())->greaterOrEqualThan(1);

$versions->sort(VersionsCollection::SORT_DESC);
Copy link
Member

Choose a reason for hiding this comment

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

Relying on internal sorting is indeed risky, and I'm sure @nikolaposa will also make these collections immutable at some point, so it is probably a good idea to cast everything to an array via iterator_to_array() and operate on that afterwards.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ocramius TBH I even planned to remove VersionsCollection class entirely in a newest 3.0.0 release, thinking it was unnecessary and nobody was using it. 😱 That's why I didn't give enough attention to its design. Feel free to open an issue describing fallacies of the class and I'll see what can be done. Of course, if you already have some idea for fixing it, open a PR along the way, I would be glad to accept it.

@nikolaposa
Copy link
Contributor

@ntzm I've implemented support for parsing v-prefixed version strings as you suggested, but release- seemed too specific, and it somehow goes beyond the scope of my library. Sorry for letting you down on that one.

As for the issue in question, feel free to open a issue (https://github.com/nikolaposa/version/issues), I would gladly consider fixing it.

@@ -280,7 +280,7 @@ public function testExecuteWithDefaultRevisionsNotProvided() : void
{
$fromSha = sha1('fromRevision', false);
$toSha = sha1('toRevision', false);
$versions = VersionsCollection::fromArray(['1.0.0', '1.0.1']);
$versions = new VersionsCollection(Version::fromString('1.0.0'), Version::fromString('1.0.1'));
Copy link
Contributor

Choose a reason for hiding this comment

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

@ntzm I see that this change caused some difficulties, because the ability to create the collection from version strings was very handy I would say now that I'm seeing use cases. Reasoning on my side was making things strict as possible, in order to avoid any ambiguity and simplify validation. So between string and Version inputs I decided to allow passing Version instances only.

I might consider introducing fromVersionStrings() and fromArray() named constructors for 3.1.0. Of course, feel free to suggest features you might find useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally think it's a good change 👍

@ntzm
Copy link
Contributor Author

ntzm commented May 4, 2018

@nikolaposa I agree with you on the release- bit, was just to line up with what composer was looking for

@Ocramius
Copy link
Member

Ocramius commented May 4, 2018

@nikolaposa I'd probably align to what composer can parse in tags

@Ocramius
Copy link
Member

About the ->current() call: do we want to wait for @nikolaposa to add something like ->last() to the collection instead?

@Ocramius Ocramius removed the WIP label May 26, 2018
@Ocramius Ocramius added this to the 1.0.0 milestone May 26, 2018
@Ocramius Ocramius closed this in 553f37e May 26, 2018
@Ocramius
Copy link
Member

This has been rebased and manually merged to master, thanks @ntzm \o/

@ntzm ntzm deleted the bump-version-version branch May 27, 2018 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow release versions such as v1.2.3 and release-1.2.3 (as well as other patterns recognized by composer)
3 participants