var assert = require("assert");
var path = require("path");

describe("Repository", function() {
  var reposPath = path.resolve("test/repos/workdir/.git");
  var newRepo = path.resolve("test/repos/newrepo");

  var Repository = require("../../lib/repository");
  var Index = require("../../lib/index");
  var Signature = require("../../lib/signature");

  before(function() {
    var test = this;

    return Repository.open(reposPath).then(function(repository) {
      test.repository = repository;
    });
  });

  it("can open a valid repository", function() {
    assert.ok(this.repository instanceof Repository);
  });

  it("cannot open an invalid repository", function() {
    return Repository.open("repos/nonrepo").then(null, function(err) {
      assert.ok(err instanceof Error);
    });
  });

  it("does not try to open paths that don't exist", function() {
    var missingPath = "/surely/this/directory/does/not/exist/on/this/machine";

    return Repository.open(missingPath).then(null, function(err) {
      assert.ok(err instanceof Error);
    });
  });

  it("can initialize a repository into a folder", function() {
    return Repository.init(newRepo, 1).then(function(path, isBare) {
      return Repository.open(newRepo);
    });
  });

  it("can read the index", function() {
    return this.repository.index().then(function(index) {
      assert.ok(index instanceof Index);
    });
  });

  it("can list remotes", function() {
    return this.repository.getRemotes().then(function(remotes) {
      assert.equal(remotes.length, 1);
      assert.equal(remotes[0], "origin");
    });
  });

  it("can get the current branch", function() {
    return this.repository.getCurrentBranch().then(function(branch) {
      assert.equal(branch.shorthand(), "master");
    });
  });

  it("can get the default signature", function() {
    var sig = this.repository.defaultSignature();

    assert(sig instanceof Signature);
  });
});

@@ -52,16 +52,101 @@
 %22path%22);
+%0Avar promisify = require(%22promisify-node%22);%0Avar fse = promisify(require(%22fs-extra%22));
 %0A%0Adescri
@@ -1327,32 +1327,249 @@
 %0A    %7D);%0A  %7D);%0A%0A
+  it(%22can utilize repository init options%22, function() %7B%0A    return fse.remove(newRepo).then(function() %7B%0A      return Repository.initExt(newRepo, %7B%0A        flags: Repository.INIT_FLAG.MKPATH%0A      %7D);%0A    %7D);%0A  %7D);%0A%0A
   it(%22can read t

add test for initExt