<commit_before>{$$, BufferedProcess, SelectListView} = require 'atom'
StatusView = require './status-view'

module.exports =
class ListView extends SelectListView
  initialize: (@data) ->
    super
    @addClass 'overlay from-top'
    @parseData()

  parseData: ->
    items = @data.split("\n ")
    branches = []
    for item in items
      branches.push {name: item}
    @setItems branches
    atom.workspaceView.append this
    @focusFilterEditor()

  getFilterKey: -> 'name'

  viewForItem: ({name}) ->
    current = false
    if name.startsWith "*"
      name = name.slice(2)
      current = true
    # $$ is an alias for View.render
    $$ ->
      @li name, =>
        @div class: 'pull-right', =>
          @span('Current') if current


  confirmed: ({name}) ->
    @changeTo name
    @cancel()

  changeTo: (branch) ->
    dir = atom.project.getRepo().getWorkingDirectory()
    new BufferedProcess
      command: 'git'
      args: ['checkout', branch]
      options:
        cwd: dir
      stdout: (data) ->
        new StatusView(type: 'success', message: data.toString())
      stderr: (data) ->
        new StatusView(type: 'alert', message: data.toString())
<commit_msg>Strip whitespace from list of branches<commit_after>{$$, BufferedProcess, SelectListView} = require 'atom'
StatusView = require './status-view'

module.exports =
class ListView extends SelectListView
  initialize: (@data) ->
    super
    @addClass 'overlay from-top'
    @parseData()

  parseData: ->
    items = @data.split("\n")
    branches = []
    for item in items
      item = item.replace(/\s/g, '')
      unless item is ''
        branches.push {name: item}
    @setItems branches
    atom.workspaceView.append this
    @focusFilterEditor()

  getFilterKey: -> 'name'

  viewForItem: ({name}) ->
    current = false
    if name.startsWith "*"
      name = name.slice(1)
      current = true
    # $$ is an alias for View.render
    $$ ->
      @li name, =>
        @div class: 'pull-right', =>
          @span('Current') if current


  confirmed: ({name}) ->
    @changeTo name
    @cancel()

  changeTo: (branch) ->
    dir = atom.project.getRepo().getWorkingDirectory()
    new BufferedProcess
      command: 'git'
      args: ['checkout', branch]
      options:
        cwd: dir
      stdout: (data) ->
        new StatusView(type: 'success', message: data.toString())
      stderr: (data) ->
        new StatusView(type: 'alert', message: data.toString())

{'fraction_non_alphanumeric': 0.14268242967794537, 'fraction_numerical': 0.0008153281695882593, 'mean_word_length': 2.5411255411255413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4010119', 'n_tokens_mistral': 753, 'n_tokens_neox': 739, 'n_words': 198}