mirror of
https://github.com/AGWA/git-crypt.git
synced 2026-01-08 03:12:28 -08:00
Write a helper function to get the version of Git
This will be useful as we start to gate code on the version of Git that's installed. A lot of code out in the wild seems to assume that the output of `git version` is "git version $VERSION", so I'm assuming it's safe for git-crypt to rely on that too.
This commit is contained in:
17
commands.cpp
17
commands.cpp
@@ -60,6 +60,23 @@ static std::string attribute_name (const char* key_name)
|
||||
}
|
||||
}
|
||||
|
||||
static std::string git_version ()
|
||||
{
|
||||
std::vector<std::string> command;
|
||||
command.push_back("git");
|
||||
command.push_back("version");
|
||||
|
||||
std::stringstream output;
|
||||
if (!successful_exit(exec_command(command, output))) {
|
||||
throw Error("'git version' failed - is Git installed?");
|
||||
}
|
||||
std::string word;
|
||||
output >> word; // "git"
|
||||
output >> word; // "version"
|
||||
output >> word; // "1.7.10.4"
|
||||
return word;
|
||||
}
|
||||
|
||||
static void git_config (const std::string& name, const std::string& value)
|
||||
{
|
||||
std::vector<std::string> command;
|
||||
|
||||
Reference in New Issue
Block a user