summaryrefslogtreecommitdiffstats
path: root/lib/utils/git.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/git.js')
-rw-r--r--lib/utils/git.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/utils/git.js b/lib/utils/git.js
index baf0fab..fc75ee3 100644
--- a/lib/utils/git.js
+++ b/lib/utils/git.js
@@ -6,11 +6,12 @@ var URI = require('urijs');
var pathUtil = require('./path');
var Promise = require('./promise');
var command = require('./command');
+var fs = require('./fs');
var GIT_PREFIX = 'git+';
function Git(tmpDir) {
- this.tmpDir = tmpDir;
+ this.tmpDir;
this.cloned = {};
}
@@ -19,11 +20,23 @@ Git.prototype.repoID = function(host, ref) {
return crc.crc32(host+'#'+(ref || '')).toString(16);
};
+// Allocate a temporary folder for cloning repos in it
+Git.prototype.allocateDir = function() {
+ var that = this;
+
+ if (this.tmpDir) return Promise();
+
+ return fs.tmpDir()
+ .then(function(dir) {
+ that.tmpDir = dir;
+ });
+};
+
// Clone a git repository if non existant
Git.prototype.clone = function(host, ref) {
var that = this;
- return Promise()
+ return this.allocateDir()
// Return or clone the git repo
.then(function() {