Move things into the construction and destruction section

This commit is contained in:
Ben Ogle
2014-09-16 14:10:49 -07:00
parent b9a63d5030
commit cc64a2c3b4

View File

@@ -47,8 +47,15 @@ class Git
EmitterMixin.includeInto(this)
Subscriber.includeInto(this)
@exists: (path) ->
if git = @open(path)
git.destroy()
true
else
false
###
Section: Class Methods
Section: Construction and Destruction
###
# Public: Creates a new Git instance.
@@ -66,17 +73,6 @@ class Git
catch
null
@exists: (path) ->
if git = @open(path)
git.destroy()
true
else
false
###
Section: Construction
###
constructor: (path, options={}) ->
@emitter = new Emitter
@repo = GitUtils.open(path)
@@ -100,6 +96,21 @@ class Git
if @project?
@subscribe @project.eachBuffer (buffer) => @subscribeToBuffer(buffer)
# Public: Destroy this {Git} object.
#
# This destroys any tasks and subscriptions and releases the underlying
# libgit2 repository handle.
destroy: ->
if @statusTask?
@statusTask.terminate()
@statusTask = null
if @repo?
@repo.release()
@repo = null
@unsubscribe()
###
Section: Event Subscription
###
@@ -175,21 +186,6 @@ class Git
else
checkoutHead()
# Public: Destroy this {Git} object.
#
# This destroys any tasks and subscriptions and releases the underlying
# libgit2 repository handle.
destroy: ->
if @statusTask?
@statusTask.terminate()
@statusTask = null
if @repo?
@repo.release()
@repo = null
@unsubscribe()
# Returns the corresponding {Repository}
getRepo: (path) ->
if @repo?