summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetar Šegina <psegina@ymail.com>2016-02-08 03:30:25 +0100
committerPetar Šegina <psegina@ymail.com>2016-02-08 03:47:10 +0100
commit81bb1fdc1f938eb02417070c40fc24b4cc678259 (patch)
treede88999788496bdc87afd4692634f9525b3e8a0e
parent30fb8ed7ee5c18b6132f452782209db2309f904c (diff)
downloadgit-hours-81bb1fdc1f938eb02417070c40fc24b4cc678259.zip
git-hours-81bb1fdc1f938eb02417070c40fc24b4cc678259.tar.gz
git-hours-81bb1fdc1f938eb02417070c40fc24b4cc678259.tar.bz2
Show error on shallow repositories
If a repository is shallow, we do not have access to the whole history, which will cause our commit lookups to fail. If a shallow repository is detected, an appropriate message is printed out and the program exits.
-rwxr-xr-xsrc/index.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js
index 9018fb9..dd1ad8f 100755
--- a/src/index.js
+++ b/src/index.js
@@ -5,6 +5,7 @@ var git = require('nodegit');
var program = require('commander');
var _ = require('lodash');
var moment = require('moment');
+var fs = require('fs');
var DATE_FORMAT = 'YYYY-MM-DD';
@@ -21,6 +22,8 @@ var config = {
};
function main() {
+ exitIfShallow();
+
parseArgs();
config = mergeDefaultsWithArgs(config);
config.since = parseSinceDate(config.since);
@@ -61,6 +64,14 @@ function main() {
});
}
+function exitIfShallow() {
+ if (fs.existsSync(".git/shallow")) {
+ console.log("Cannot analyze shallow copies!");
+ console.log("Please run git fetch --unshallow before continuing!");
+ process.exit(1);
+ }
+}
+
function parseArgs() {
function int(val) {
return parseInt(val, 10);