2015-07-13 07:36:48 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
// Dependencies
|
|
|
|
var ReadJson = require("r-json")
|
|
|
|
, WriteJson = require("w-json")
|
|
|
|
, Abs = require("abs")
|
|
|
|
, Logger = require("bug-killer")
|
|
|
|
;
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
const DATA_FILE = Abs("~/.git-stats");
|
|
|
|
|
|
|
|
function migrate() {
|
|
|
|
try {
|
|
|
|
var data = ReadJson(DATA_FILE)
|
|
|
|
} catch (e) {
|
|
|
|
if (e.code === "ENOENT") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Logger.log(e);
|
|
|
|
}
|
|
|
|
|
2016-02-27 18:30:23 +01:00
|
|
|
data.commits = data.commits || {};
|
|
|
|
var newStats = { commits: data.commits };
|
|
|
|
delete data.commits;
|
2015-07-13 07:36:48 +02:00
|
|
|
Object.keys(data).forEach(function (day) {
|
2016-02-27 18:30:23 +01:00
|
|
|
var cDay = newStats.commits[day] = newStats.commits[day] || {};
|
2015-07-13 07:36:48 +02:00
|
|
|
Object.keys(data[day]).map(function (c) {
|
|
|
|
Object.keys(data[day][c]).map(function (h) {
|
|
|
|
cDay[h] = 1;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
WriteJson(DATA_FILE, newStats);
|
|
|
|
}
|
|
|
|
|
|
|
|
migrate();
|
2016-02-27 18:30:23 +01:00
|
|
|
|