2017-03-22 20:13:24 -07:00
|
|
|
// vim: filetype=cpp :
|
2017-03-22 22:01:34 -07:00
|
|
|
#include <iostream>
|
2017-03-23 15:13:52 -07:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-03-22 20:13:24 -07:00
|
|
|
|
2017-03-23 19:09:36 -07:00
|
|
|
#include "cellar.hpp"
|
2017-03-22 22:01:34 -07:00
|
|
|
#include "commands.hpp"
|
2017-03-23 18:51:11 -07:00
|
|
|
#include "output.hpp"
|
2017-03-22 20:13:24 -07:00
|
|
|
#include "version.hpp"
|
|
|
|
|
2017-03-22 22:01:34 -07:00
|
|
|
using namespace std;
|
|
|
|
using namespace cellar::version;
|
|
|
|
|
2017-03-22 20:13:24 -07:00
|
|
|
string cellar::version::short_version() {
|
|
|
|
/*[[[cog
|
|
|
|
import cog
|
2017-03-22 22:01:34 -07:00
|
|
|
import configparser
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
today = datetime.datetime.today()
|
|
|
|
|
|
|
|
cparse = configparser.ConfigParser()
|
2017-03-23 11:13:21 -07:00
|
|
|
cparse.read("cogrc")
|
2017-03-22 22:01:34 -07:00
|
|
|
config = cparse["version"]
|
2017-03-22 20:42:08 -07:00
|
|
|
|
2017-03-22 22:01:34 -07:00
|
|
|
if config.getboolean("release"):
|
|
|
|
outstring = "version {0}, built {1}".format(config["release_version"], str(today))
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
import subprocess
|
|
|
|
cmdoutput = subprocess.check_output(["git", "symbolic-ref", "HEAD"]).decode().strip()
|
|
|
|
gitbranch = cmdoutput.split("/")[2]
|
2017-03-22 20:13:24 -07:00
|
|
|
|
2017-03-22 22:01:34 -07:00
|
|
|
githash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
|
|
|
|
outstring = "{0} {1}, built {2}".format(gitbranch, githash, str(today))
|
|
|
|
except:
|
|
|
|
outstring = "exception raised when trying to read git data at precompile time"
|
|
|
|
raise
|
|
|
|
|
2017-03-22 23:23:15 -07:00
|
|
|
cog.outl("return string(\"{0}\");".format(outstring))
|
2017-03-22 20:13:24 -07:00
|
|
|
]]]*/
|
|
|
|
//[[[end]]]
|
|
|
|
}
|
2017-03-22 22:01:34 -07:00
|
|
|
|
2017-03-23 19:09:36 -07:00
|
|
|
void cellar::print_version(int argc, vector<string> argv) {
|
2017-03-23 18:51:11 -07:00
|
|
|
cellar::output::statement(short_version());
|
2017-03-22 22:01:34 -07:00
|
|
|
}
|