Skip to content

Commit ff61343

Browse files
author
Luca
committed
testRepo zipped
1 parent ead6642 commit ff61343

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

.Makefile.kate-swp

34 Bytes
Binary file not shown.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
test/testRepo

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
test:
2+
@unzip test/testRepo.zip -d test/
23
@./node_modules/.bin/mocha --ignore-leaks
34
.PHONY: test

lib/repo.js

+21-10
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,35 @@ Repo.prototype.getBranches = function (callback) {
3030
, heads = {}
3131
, cb = callback || noop
3232
, fn
33+
, files = []
34+
, stat
3335
;
3436

35-
fs.readdir(headsDir, function (err, files) {
37+
fs.readdir(headsDir, function (err, content) {
3638
if (err) {
3739
cb(err, null);
3840
}
3941

4042
fn = function (filename, cb) {
41-
fs.readFile(path.join(headsDir, filename), 'utf8', function (err, content) {
42-
var obj = {};
43-
if (err) {
44-
return cb(err, null);
45-
}
46-
obj[filename] = content.slice(0, -1);
47-
return cb(err, obj);
48-
});
43+
var file_path = path.join(headsDir, filename);
44+
fs.readFile(file_path, 'utf8', function (err, content) {
45+
var obj = {};
46+
if (err) {
47+
return cb(err, null);
48+
}
49+
obj[filename] = content.slice(0, -1);
50+
return cb(null, obj);
51+
});
4952
};
50-
async.map(files, fn, cb);
53+
54+
content.forEach(function (filename) {
55+
stat = fs.statSync(path.join(headsDir, filename));
56+
if (stat.isFile()) {
57+
files.push(filename);
58+
}
59+
});
60+
61+
async.map(files, fn, cb);
5162
});
5263
};
5364

test/repo.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ var repo = require('../lib/repo.js')
55
;
66

77
describe('repo', function() {
8-
var validRelativePath = './test/TestGitRepo'
8+
var validRelativePath = './test/testRepo'
99
, invalidRelativePath = './test'
1010
, validAbsolutePath = path.resolve(validRelativePath)
1111
, invalidAbsolutePath = path.resolve(invalidRelativePath)
1212
, arrayOfBranch = [ { develop: 'e42d12f3d9f9c47bdd79a0bb837cfdf50d4a58af' }
13-
, { master: '5c95ba4bd7969740f402a07b4e06bbf351124d65' } ]
13+
, { master: 'e42d12f3d9f9c47bdd79a0bb837cfdf50d4a58af' } ]
1414
, blob = "303ff981c488b812b6215f7db7920dedb3b59d9a"
1515
, tree = "324e16519b70c18a9c92db30aa800912ec7f41be"
1616
, commit = "e42d12f3d9f9c47bdd79a0bb837cfdf50d4a58af"

test/testRepo.zip

23.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)