Skip to content

Commit

Permalink
fix building from a tag with a modified working directory [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
cfillion committed Apr 14, 2024
1 parent 5af2ed0 commit ba1e2f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/compstr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class Version {
static constexpr auto compute()
{
constexpr const char *start { **ver == 'v' ? *ver + 1 : *ver },
*end { lfind<ver>('-', start, *ver + sizeof(*ver)) };
*dirty { lfind<ver>('+', start, *ver + sizeof(*ver)) },
*end { lfind<ver>('-', start, dirty) };
std::array<char, end - start> version {};
for(size_t i {}; i < version.size() - 1; ++i) {
const char c { start[i] };
Expand Down
2 changes: 2 additions & 0 deletions tests/compstr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ TEST(CompStrTest, Version) {
static constexpr const char
g_underscores[] { "1_20_3" },
g_gitdescribe[] { "v0.8.7.4-41-g6d2c9f5" },
g_dirtygittag[] { "v0.9+" },
g_return_asis[] { "0.8.7" };

EXPECT_STREQ(CompStr::version<&g_underscores>, "1.20.3");
EXPECT_STREQ(CompStr::version<&g_gitdescribe>, "0.8.7.4");
EXPECT_STREQ(CompStr::version<&g_dirtygittag>, "0.9");
EXPECT_STREQ(CompStr::version<&g_return_asis>, "0.8.7");
}

Expand Down

0 comments on commit ba1e2f0

Please sign in to comment.