Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support git shallow clones

  • Loading branch information...
commit 161165fd34c007a7f5b4f4d6f3539a64de285c4d 1 parent f3e9960
@springmeyer springmeyer authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/gitutil.js
View
16 lib/gitutil.js
@@ -1,13 +1,21 @@
var exec = require('child_process').exec;
var fs = require('fs');
+var package_json = require('../package.json');
-var child = exec('git describe --tags',
+var child = exec('git describe --tags --always',
function(error, stdout, stderr) {
if (error !== null) {
- console.log('exec error: ' + error);
+ console.log('exec error: ' + error);
} else {
var hash = stdout;
- var version_file = hash + hash.slice(1, -10).replace('-', '.') + '\n';
- fs.writeFileSync('VERSION', version_file);
+ if (hash[0] == 'v') {
+ // git describe actually found a tag
+ var version_file = hash + hash.slice(1, -10).replace('-', '.') + '\n';
+ fs.writeFileSync('VERSION', version_file);
+ } else {
+ // no tag found likely due to shallow clone (--depth=N)
+ var version_file = 'v' + package_json.version + '-' + hash;
+ fs.writeFileSync('VERSION', version_file);
+ }
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.