 StatusView = require './status-view'
 
 module.exports =
+  currentPane: null
+  dir: ''
+  commitFilePath: -> @dir + '/.git/COMMIT_EDITMSG'
+
   activate: (state) ->
     @dir = atom.project.getRepo().getWorkingDirectory()
-    @commitFilePath = @dir + '/.git/COMMIT_EDITMSG'
+    @commitFilePath()
     atom.workspaceView.command "git-plus:commit", => @gitStatus()
 
   deactivate: ->

    # gitPlusViewState: @gitPlusView.serialize()

  gitStatus: ->
    process = new BufferedProcess({
      command: 'git'
      args: ['status']

    @showFile()

  showFile: ->
    atom.workspace.open @commitFilePath(), split: 'right', activatePane: true
    PathWatcher.watch @commitFilePath(), (event) =>
      if event is 'change'
        @commit()

  commit: ->
    process = new BufferedProcess({
      command: 'git'
      args: ['commit', "--file=#{@commitFilePath()}"]
      options:
        cwd: @dir
      stdout: (data) =>
        PathWatcher.closeAllWatchers()
        atom.workspace.destroyActivePane()
        @currentPane.activate()
      stderror: (data) =>
        alert data.toString()
    })
