diff --git a/spec/app/git-spec.coffee b/spec/app/git-spec.coffee index fc9c85f46..522d38d8e 100644 --- a/spec/app/git-spec.coffee +++ b/spec/app/git-spec.coffee @@ -21,11 +21,11 @@ describe "Git", -> describe ".getPath()", -> it "returns the repository path for a .git directory path", -> repo = new Git(require.resolve('fixtures/git/master.git/HEAD')) - expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git') + '/' + expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git') it "returns the repository path for a repository path", -> repo = new Git(require.resolve('fixtures/git/master.git')) - expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git') + '/' + expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git') describe ".getHead()", -> it "returns a branch name for a non-empty repository", -> diff --git a/src/app/git.coffee b/src/app/git.coffee index 866e2977f..1c9fffc0a 100644 --- a/src/app/git.coffee +++ b/src/app/git.coffee @@ -1,10 +1,10 @@ _ = require 'underscore' +fs = require 'fs' Subscriber = require 'subscriber' GitRepository = require 'git-repository' module.exports = class Git - @open: (path, options) -> try new Git(path, options) @@ -37,7 +37,8 @@ class Git refreshIndex: -> @getRepo().refreshIndex() - getPath: -> @getRepo().getPath() + getPath: -> + @path ?= fs.absolute(@getRepo().getPath()) destroy: -> @getRepo().destroy() @@ -45,8 +46,7 @@ class Git @unsubscribe() getWorkingDirectory: -> - repoPath = @getPath() - repoPath?.substring(0, repoPath.length - 6) + @getPath()?.replace(/\/\.git\/?/, '') getHead: -> @getRepo().getHead() ? ''