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

class RemoteController < ApplicationController
  ALL_REMOTES = "...all remotes..."
  
  include SubmoduleHelper::Update
  
  before_filter :set_script_at_top
  def set_script_at_top
    @script_at_top = true
  end
  
  def fetch
    branch = git.branch.current_branch
    branch_remote = branch && branch_remote
    
    for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.remote.names, :default => branch.remote.name) do |remote_name|
      puts "<h2>Fetching from #{remote_name}</h2>"
      output = run_fetch(remote_name)
      puts htmlize(output[:text])
      
      unless output[:fetches].empty?
        puts("<h2>Log of changes fetched</h2>")
        output_branch_logs(output[:fetches])
      end
      
      puts "<h2>Pruning stale branches from #{remote_name}</h2>"
      puts git.command('remote', 'prune', remote_name)
      puts "<p>Done.</p>"
    end
  end
  
  def pull
    if (branch = git.branch.current_branch).nil?
      puts "You can't pull while not being on a branch (and you are not on a branch).  Please switch to a branch, and try again."
      output_show_html and return
    end
    
    remote_names = git.remote.names.with_this_at_front(branch.remote_name)
    
    TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => remote_names) do |remote_name|<commit_msg>allow fetching while not on a remote<commit_after>require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'

class RemoteController < ApplicationController
  ALL_REMOTES = "...all remotes..."
  
  include SubmoduleHelper::Update
  
  before_filter :set_script_at_top
  def set_script_at_top
    @script_at_top = true
  end
  
  def fetch
    if (branch = git.branch.current_branch)
      default_remote = branch_remote.name
    else
      default_remote = git.remote.names.with_this_at_front("origin").first
    end
    
    for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.remote.names, :default => default_remote) do |remote_name|
      puts "<h2>Fetching from #{remote_name}</h2>"
      output = run_fetch(remote_name)
      puts htmlize(output[:text])
      
      unless output[:fetches].empty?
        puts("<h2>Log of changes fetched</h2>")
        output_branch_logs(output[:fetches])
      end
      
      puts "<h2>Pruning stale branches from #{remote_name}</h2>"
      puts git.command('remote', 'prune', remote_name)
      puts "<p>Done.</p>"
    end
  end
  
  def pull
    if (branch = git.branch.current_branch).nil?
      puts "You can't pull while not being on a branch (and you are not on a branch).  Please switch to a branch, and try again."
      output_show_html and return
    end
    
    remote_names = git.remote.names.with_this_at_front(branch.remote_name)
    
    TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => remote_names) do |remote_name|
{'fraction_non_alphanumeric': 0.11674449633088725, 'fraction_numerical': 0.004002668445630421, 'mean_word_length': 3.2965616045845274, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4142678', 'n_tokens_mistral': 960, 'n_tokens_neox': 952, 'n_words': 239}