Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

robustness of reading a version tag #6

Closed
cordoval opened this issue Jan 26, 2014 · 2 comments
Closed

robustness of reading a version tag #6

cordoval opened this issue Jan 26, 2014 · 2 comments

Comments

@cordoval
Copy link
Contributor

can we make the toBuilder more robust?

$builder = Parser::toBuilder($lastTag);
  [Herrera\Version\Exception\InvalidStringRepresentationException]
  The version string representation "v1.0.0" is invalid.
@ghost
Copy link

ghost commented Jan 26, 2014

Hmm, this is a tough call.

This library tries to be very strict with the Semantic Versioning specifications, and prefixing version numbers with "v" is not part of the spec. In fact, there was a tiny mention about it.

I know that it is probably trivial, but my feeling is that I don't want to support it.

Something people can use is:

$builder = Parser::toBuilder(ltrim($lastTag, 'v'));

And if it's something that is frequently used in a library, the class can be extended to support the "v" prefix:

use Herrera\Version\Parser as Base

class Parser extends Base
{
    public static function toBuilder($version)
    {
        return parent::toBuilder(ltrim($version, 'v'));
    }
}

@cordoval
Copy link
Contributor Author

I solved it as you can see in Gush PR, yeah Gush is using php-version 👶
my use case was as in the PR since when I tag or shown also on the git book one does git tag -a v1.0.0 -m "text here"

anyway closing, good to have your thoughts on this

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

No branches or pull requests

1 participant