           @renderChanges()
         , 10)
 
+  commit: ->
+    commitPromise = @changes.commit(@commitMessageModel.getText()).then =>
+      @commitMessageModel.setText('')
+      @renderChanges()
+
 module.exports = document.registerElement 'git-experiment-changes-view', prototype: ChangesView.prototype

    @selectChange @querySelector("[data-path='#{path}'][data-state='#{state}']")

    @changes.getPatch(path, state).then (patch) =>
      console.log patch
      setImmediate ->
        patchView = new PatchView
        patchView.setPatch(patch)
        diffsNode.appendChild(patchView)
        diffsNode.style.webkitTransform = 'scale(1)' # fixes redraw issues

  selectChange: (el) ->
    return unless el

      commitNode.classList.remove('selected')

    el.classList.add('selected')

    @selectedPath = el.dataset['path']
    @selectedState = el.dataset['state']

    if @unstagedChangesNode.offsetHeight + @unstagedChangesNode.scrollTop - el.offsetTop - el.offsetHeight < 0
      el.scrollIntoView(false) # off the bottom of the scroll
