aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Romero <romerosanchezv@gmail.com>2020-10-27 14:36:22 -0700
committerGitHub <noreply@github.com>2020-10-27 14:36:22 -0700
commitaf9d0701bec38c194e0706e0f4c6022a2275c369 (patch)
tree9a6b983e3f24a87492fc4436fbb53e16274209fe
parent18f84f2fb986e3a3d8d37d868168b202eef0e45f (diff)
downloadvcpkg-af9d0701bec38c194e0706e0f4c6022a2275c369.tar.gz
vcpkg-af9d0701bec38c194e0706e0f4c6022a2275c369.zip
[vcpkg] Always use version-string in generator (#14262)
* Always use version-string in generator * Fix formatting
-rw-r--r--.gitignore5
-rw-r--r--toolsrc/src/vcpkg/commands.porthistory.cpp63
2 files changed, 8 insertions, 60 deletions
diff --git a/.gitignore b/.gitignore
index a3d42ed70..ed388f4a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -320,3 +320,8 @@ archives
.DS_Store
prefab/
*.swp
+
+###################
+# Codespaces
+###################
+pythonenv3.8/
diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp
index aa011b999..045562136 100644
--- a/toolsrc/src/vcpkg/commands.porthistory.cpp
+++ b/toolsrc/src/vcpkg/commands.porthistory.cpp
@@ -24,7 +24,6 @@ namespace vcpkg::Commands::PortHistory
std::string version_string;
std::string version;
int port_version;
- Versions::Scheme scheme;
};
const System::ExitCodeAndOutput run_git_command_inner(const VcpkgPaths& paths,
@@ -54,54 +53,10 @@ namespace vcpkg::Commands::PortHistory
bool is_date(const std::string& version_string)
{
- // The date regex is not complete, it matches strings that look like dates,
- // e.g.: 2020-99-99.
- //
- // The regex has two capture groups:
- // * Date: "^([0-9]{4,}[-][0-9]{2}[-][0-9]{2})", it matches strings that resemble YYYY-MM-DD.
- // It does not validate that MM <= 12, or that DD is possible with the given MM.
- // YYYY should be AT LEAST 4 digits, for some kind of "future proofing".
- std::regex re("^([0-9]{4,}[-][0-9]{2}[-][0-9]{2})((?:[.|-][0-9a-zA-Z]+)*)$");
- return std::regex_match(version_string, re);
- }
-
- bool is_date_without_tags(const std::string& version_string)
- {
std::regex re("^([0-9]{4,}[-][0-9]{2}[-][0-9]{2})$");
return std::regex_match(version_string, re);
}
- bool is_semver(const std::string& version_string)
- {
- // This is the "official" SemVer regex, taken from:
- // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
- std::regex re("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*"
- ")(?:\\.(?:0|["
- "1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
- return std::regex_match(version_string, re);
- }
-
- bool is_semver_relaxed(const std::string& version_string)
- {
- std::regex re("^(?:[0-9a-zA-Z]+)\\.(?:[0-9a-zA-Z]+)\\.(?:[0-9a-zA-Z]+)(?:[\\.|-|\\+][0-9a-zA-Z]+)*$");
- return std::regex_match(version_string, re);
- }
-
- const Versions::Scheme guess_version_scheme(const std::string& version_string)
- {
- if (is_date(version_string))
- {
- return Versions::Scheme::Date;
- }
-
- if (is_semver(version_string) || is_semver_relaxed(version_string))
- {
- return Versions::Scheme::Relaxed;
- }
-
- return Versions::Scheme::String;
- }
-
std::pair<std::string, int> clean_version_string(const std::string& version_string,
int port_version,
bool from_manifest)
@@ -120,7 +75,7 @@ namespace vcpkg::Commands::PortHistory
if (index != std::string::npos)
{
// Very lazy check to keep date versions untouched
- if (!is_date_without_tags(version_string))
+ if (!is_date(version_string))
{
auto maybe_port_version = version_string.substr(index + 1);
clean_version.resize(index);
@@ -165,8 +120,7 @@ namespace vcpkg::Commands::PortHistory
commit_date,
Strings::concat(clean_version.first, "#", std::to_string(clean_version.second)),
clean_version.first,
- clean_version.second,
- guess_version_scheme(clean_version.first)};
+ clean_version.second};
}
}
@@ -276,18 +230,7 @@ namespace vcpkg::Commands::PortHistory
{
Json::Object object;
object.insert("git-tree", Json::Value::string(version.git_tree));
- switch (version.scheme)
- {
- case Versions::Scheme::Semver: // falls through
- case Versions::Scheme::Relaxed:
- object.insert("version", Json::Value::string(version.version));
- break;
- case Versions::Scheme::Date:
- object.insert("version-date", Json::Value::string(version.version));
- break;
- case Versions::Scheme::String: // falls through
- default: object.insert("version-string", Json::Value::string(version.version)); break;
- }
+ object.insert("version-string", Json::Value::string(version.version));
object.insert("port-version", Json::Value::integer(version.port_version));
versions_json.push_back(std::move(object));
}