Add Git.destroy() that frees native repository

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-01-09 17:07:29 -08:00
parent d5a23f770f
commit caffda6027
4 changed files with 30 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
$ = require 'jquery'
_ = require 'underscore'
Subscriber = require 'subscriber'
module.exports =
class Git
@@ -23,12 +25,17 @@ class Git
constructor: (path) ->
@repo = new GitRepository(path)
$(window).on 'focus', => @refreshIndex()
@subscribe $(window), 'focus', => @refreshIndex()
refreshIndex: -> @repo.refreshIndex()
getPath: -> @repo.getPath()
destroy: ->
@repo.destroy()
@repo = null
@unsubscribe()
getWorkingDirectory: ->
repoPath = @getPath()
repoPath?.substring(0, repoPath.length - 6)
@@ -85,3 +92,5 @@ class Git
isSubmodule: (path) ->
@repo.isSubmodule(@relativize(path))
_.extend Git.prototype, Subscriber

View File

@@ -34,6 +34,8 @@ class Project
grammarOverridesByPath: @grammarOverridesByPath
destroy: ->
@repo?.destroy()
@repo = null
editSession.destroy() for editSession in @getEditSessions()
addGrammarOverrideForPath: (path, grammar) ->