<commit_before>require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'

class StashController < ApplicationController
  layout "application", :except => ["clear"]
  def show
    if git.stash.list.empty?
      puts "Stash list is empty"
    end

    stash_item = select_stash

    if stash_item.nil?
      puts "Aborted"
      return
    end

    Formatters::Diff.new() do |f|
      f.header("Diff for stash ‘#{stash_item[:description]}’")
      f.content(git.stash.diff(stash_item[:name]))
    end
  end
  
  def apply
    stash_item = select_stash(:prompt => "Select a stash to apply")
    if stash_item.nil?
      puts "Cancelled"
      return
    end
    puts "<h2>Applying stash '#{stash_item[:description]}'</h2>"
    flush

    stash_it = lambda {
      git.stash.apply(stash_item[:name])
    }

    result = stash_it.call

    if result.match(/Cannot restore on top of a dirty state/)
      response = TextMate::UI.alert(:warning, "You're not on a clean working copy", "You may want to commit your outstanding changes before stashing.\nWould you like to apply your stash anyways? (could cause conflicts)", "No", "Yes")
      if response == "Yes"
        git.command("add", ".")
        result = stash_it.call
        git.command("reset")<commit_msg>show stash command is working again<commit_after>require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'

class StashController < ApplicationController
  layout "application", :except => ["clear"]
  def show
    if git.stash.list.empty?
      puts "Stash list is empty"
    end

    stash_item = select_stash

    if stash_item.nil?
      puts "Aborted"
      return
    end
    
    puts "<h2>Diff for stash ‘#{stash_item[:description]}’</h2>"
    render("diff/_diff_results", :locals => {:diff_results => (git.stash.diff(stash_item[:name]))})
  end
  
  def apply
    stash_item = select_stash(:prompt => "Select a stash to apply")
    if stash_item.nil?
      puts "Cancelled"
      return
    end
    puts "<h2>Applying stash '#{stash_item[:description]}'</h2>"
    flush

    stash_it = lambda {
      git.stash.apply(stash_item[:name])
    }

    result = stash_it.call

    if result.match(/Cannot restore on top of a dirty state/)
      response = TextMate::UI.alert(:warning, "You're not on a clean working copy", "You may want to commit your outstanding changes before stashing.\nWould you like to apply your stash anyways? (could cause conflicts)", "No", "Yes")
      if response == "Yes"
        git.command("add", ".")
        result = stash_it.call
        git.command("reset")
{'fraction_non_alphanumeric': 0.12504946576968737, 'fraction_numerical': 0.002374356944994064, 'mean_word_length': 3.0063391442155307, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '3302350', 'n_tokens_mistral': 828, 'n_tokens_neox': 822, 'n_words': 224}