Skip to content

Commit

Permalink
Add helpers to faciliate Git version comparison
Browse files Browse the repository at this point in the history
This will be useful as we start to gate code on the version of Git that's installed.
  • Loading branch information
AGWA committed May 17, 2015
1 parent 439bcd8 commit c279a6a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> command;
command.push_back("git");
Expand All @@ -77,6 +77,31 @@ static std::string git_version ()
return word;
}

static std::vector<int> parse_version (const std::string& str)
{
std::istringstream in(str);
std::vector<int> version;
std::string component;
while (std::getline(in, component, '.')) {
version.push_back(std::atoi(component.c_str()));
}
return version;
}

static std::vector<int> git_version ()
{
return parse_version(git_version_string());
}

static std::vector<int> make_version (int a, int b, int c)
{
std::vector<int> 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<std::string> command;
Expand Down

0 comments on commit c279a6a

Please sign in to comment.