neargye / semver Goto Github PK
View Code? Open in Web Editor NEWSemantic Versioning for modern C++
License: MIT License
Semantic Versioning for modern C++
License: MIT License
Hi,
I am trying to use from_string(). I am also using Qt.
Below code works fine:
semver::version version_in_db = semver::from_string(QString("1.0.0").toStdString());
But the below code fails with an exeption of 'invalid argument':
semver::version version_in_db = semver::from_string(QString("1.0.0-beta").toStdString());
Adding the '-beta' seems to be causing it to fail.
An example version:
$ git describe --dirty
0.0.2-19-g084f5d4-dirty
You can check here that it is a valid Semantic Version
https://regex101.com/r/vkijKf/1/
Thanks!
Cheers!
Hi @Neargye,
thanks for implementing semver! We've been using it in our project since version 0.1.8, but had to add the build metadata ourselves. It would be nice if you could add this also to the official repo.
https://semver.org/#spec-item-10
We use it to store and compare the build hash.
Example:
1.4.0-alpha.1+6703c608
Hi! I created a pull request to the vcpkg repository adding support for your library that you can see here: microsoft/vcpkg#12406. Alas, maintainers requested that the name in vcpkg be changed to something more specific than semver
which they deemed to generic given the unestabilished status of the library.
Do you have any other preferences or should we go with the proposed Neargye-semver
?
Closing the issue, found what I was doing wrong.
FFR - and maybe should be added to README.md in the vcpkg section
in CMakeLists.txt
use the following:
find_package(semver CONFIG REQUIRED)
Hey, could you add support for ranges to the library? These are not in the official standard, but are still widely used.
Example: ^1.2.3
means >= 1.2.3 && < 2.0.0
So maybe add a class semver::range
with:
inRange()
method that takes a single semver object and checks if the passed semver fits into the rangeHere's the node documentation for semver ranges. This github project also has test cases.
The test
TEST_CASE("semver::from_string", "[demo]")
{
using namespace semver;
// auto version = semver::from_string("1.0.0"); // SUCCEEDS
auto version = semver::from_string("1.0"); // FAILS
REQUIRE(version == "1.0.0"_version);
}
fails with an exception
semver::version::from_string invalid version.
It is quite common to omit the patch version. So the from_string
/from_chars
function pair should be robust against the omission and add .0
.
Is there any chance to have ^
and ~
supported in range
parser?
Example: https://devhints.io/semver
Hi,
is there an option to check for new beta versions as well?
When comparing 0.10.0-beta.2 > 0.10.0-beta.1
, the result will be FALSE.
I'd also like to check if the beta version increased.
Best regards
Axel
Hi,
I think I found a bug.
5.99.999 is valid occurding to semver.org but does not parse:
auto v = semver::from_string("5.99.999");
I get an exception:
C++ exception with description "semver::version::from_string invalid version."
Nice header-only project, but unfortunately not usable for me, because the following code throws an exeption (semver::version::from_string invalid version).
semver::version vNew = semver::from_string("1.37.0-1");
According to semver.org, this is a valid version with "pre-release" tag.
Like the title suggests, using https://regex101.com/r/Ly7O1x/3/ to validate it it appears to be a valid value, yet the library trips over it.
1.0.0-alpha.beta is valid occurding to semver.org but does not parse
Checking the semver rules I am unsure whether a limitation to a value range from 0..255 (i.e. a limitation to std::uint8_t
) is
Could you please explain your design decision?
Hello,
Thanks for your nice library.
Trying to compile it with clang 6.0.1 results on compiler error : constexpr function never produces a constant expression
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:513:26: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
auto is_logical_or = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::logical_or; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:513:74: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
auto is_logical_or = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::logical_or; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
range_parser parser{str_};
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:515:24: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
auto is_operator = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::range_operator; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:515:72: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
auto is_operator = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::range_operator; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
range_parser parser{str_};
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:517:22: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
auto is_number = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::number; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:517:70: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
auto is_number = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::number; };
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
range_parser parser{str_};
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:581:9: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
default:
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:609:53: warning: constructor parameter 'text' shadows the field 'text' of 'range_lexer' [-Wshadow-field-in-constructor]
constexpr explicit range_lexer(std::string_view text) noexcept : text{text}, pos{0} {}
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:606:22: note: previous declaration is here
std::string_view text;
^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:794:3: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
default:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.