<commit_before>GitHub.helper :project do
  `git config --get remote.origin.url`.chomp.split('/').last.chomp('.git')
end

GitHub.register :open do 
  if remote = `git config --get remote.origin.url`.chomp
    exec "open https://github.com/#{remote.split(/github.com[:|\/]/).last.chomp('.git')}"
  end
end

GitHub.register :info do |repo, dude|
  puts "== Grabbing info for #{repo} #{dude}"
end

GitHub.describe :pull => 'hi, this is github pull'
GitHub.register :pull do |user, branch|
  branch ||= 'master'
  value    = git "remote show #{user}"

  if value.error? && value =~ /no such remote/i
    git "remote add #{user} git://github.com/#{user}/#{helper.project}.git"
  elsif value.error?
    die "Error: #{value}"
  end

  puts "Switching to #{user}/#{branch}"

  if git("checkout -b #{user}/#{branch}").error? && (checkout = git "checkout #{user}/#{branch}").error?
    puts checkout
    return
  end

  pgit "pull #{user} #{branch}"
end<commit_msg>DRY up the commands by adding some useful helpers<commit_after>GitHub.helper :user_and_project_for do |remote|
  url_for(remote).split(/[:\/]/, 2).last.split('/')
end

GitHub.helper :user_for do |remote|
  user_and_project_for(remote).first
end

GitHub.helper :project do
  user_and_project_for(:origin).last.chomp('.git')
end

GitHub.helper :url_for do |remote|
  `git config --get remote.#{remote}.url`.chomp
end

GitHub.helper :current_user do
  user_for(:origin)
end

GitHub.helper :public_url_for do |user|
  "git://github.com/#{user}/#{project}.git"
end

GitHub.register :open do 
  if helper.project
    exec "open https://github.com/#{helper.current_user}/#{helper.project}"
  end
end

GitHub.register :status do
  puts "== Status right now for #{helper.project}"
  puts "You are #{helper.current_user}"
end

GitHub.register :info do |repo, dude|
  puts "== Grabbing info for #{repo} #{dude}"
end

GitHub.describe :pull => 'hi, this is github pull'
GitHub.register :pull do |user, branch|
  branch ||= 'master'
  value    = git "remote show #{user}"

  if value.error? && value =~ /no such remote/i
    git "remote add #{user} #{helper.public_url_for(user)}"
  elsif value.error?
    die "Error: #{value}"
  end

  puts "Switching to #{user}/#{branch}"

  if git("checkout -b #{user}/#{branch}").error? && (checkout = git "checkout #{user}/#{branch}").error?
    puts checkout
    return
  end

  pgit "pull #{user} #{branch}"
end
{'fraction_non_alphanumeric': 0.17349498327759197, 'fraction_numerical': 0.0004180602006688963, 'mean_word_length': 3.9238683127572016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4384789', 'n_tokens_mistral': 856, 'n_tokens_neox': 842, 'n_words': 229}