diff --git a/commands.cpp b/commands.cpp index f984132..f8e9f23 100644 --- a/commands.cpp +++ b/commands.cpp @@ -60,7 +60,7 @@ static std::string attribute_name (const char* key_name) } } -static std::string git_version () +static std::string git_version_string () { std::vector command; command.push_back("git"); @@ -77,6 +77,31 @@ static std::string git_version () return word; } +static std::vector parse_version (const std::string& str) +{ + std::istringstream in(str); + std::vector version; + std::string component; + while (std::getline(in, component, '.')) { + version.push_back(std::atoi(component.c_str())); + } + return version; +} + +static std::vector git_version () +{ + return parse_version(git_version_string()); +} + +static std::vector make_version (int a, int b, int c) +{ + std::vector version; + version.push_back(a); + version.push_back(b); + version.push_back(c); + return version; +} + static void git_config (const std::string& name, const std::string& value) { std::vector command;