Skip to content

Commit 1a65463

Browse files
committed
Merge pull request nodegit#317 from nodegit/fix-repo-initExt
Fix repo init ext
2 parents 7e1a27b + ea2a390 commit 1a65463

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/repository.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var Revwalk = require("./revwalk");
77
var Commit = require("./commit");
88
var Remote = require("./remote");
99
var Promise = require("nodegit-promise");
10+
var normalizeOptions = require("./util/normalize_options");
1011

1112
var TreeBuilder = NodeGit.Treebuilder;
1213
var Repository = NodeGit.Repository;
@@ -641,4 +642,12 @@ Repository.prototype.mergeBranches = function(to, from, signature) {
641642
});
642643
};
643644

645+
// Override Repository.initExt to normalize initoptions
646+
var initExt = Repository.initExt;
647+
Repository.initExt = function(repo_path, opts) {
648+
opts = normalizeOptions(opts, NodeGit.RepositoryInitOptions);
649+
return initExt(repo_path, opts);
650+
};
651+
652+
644653
module.exports = Repository;

test/tests/repository.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var assert = require("assert");
22
var path = require("path");
3+
var promisify = require("promisify-node");
4+
var fse = promisify(require("fs-extra"));
35

46
describe("Repository", function() {
57
var reposPath = path.resolve("test/repos/workdir/.git");
@@ -41,6 +43,14 @@ describe("Repository", function() {
4143
});
4244
});
4345

46+
it("can utilize repository init options", function() {
47+
return fse.remove(newRepo).then(function() {
48+
return Repository.initExt(newRepo, {
49+
flags: Repository.INIT_FLAG.MKPATH
50+
});
51+
});
52+
});
53+
4454
it("can read the index", function() {
4555
return this.repository.index().then(function(index) {
4656
assert.ok(index instanceof Index);

0 commit comments

Comments
 (0)