Skip to content
Browse files

Remove unused thor files

  • Loading branch information...
1 parent 0aa6bf3 commit fa7b766d0f67a771c28033157dc0ad5946769d34 @joshuaclayton committed Jun 21, 2012
Showing with 0 additions and 216 deletions.
  1. +0 −129 thor.d/deployment.thor
  2. +0 −75 thor.d/github.thor
  3. +0 −12 thor.d/heroku.thor
View
129 thor.d/deployment.thor
@@ -1,129 +0,0 @@
-#!/usr/bin/env ruby
-
-require "active_support"
-
-module GitCommands
- require "colored"
- class ShellError < RuntimeError; end
-
- @logging = ENV['LOGGING'] != "false"
-
- def self.run(cmd, *expected_exitstatuses)
- log_output("+ #{cmd}", :bold, :green)
-
- output = `#{cmd} 2>&1`
-
- log_output(output, :strip, lambda {|s| s.gsub(/^/, " ") }, :bold, :yellow)
- log_output("\n")
-
- expected_exitstatuses << 0 if expected_exitstatuses.empty?
-
- unless [expected_exitstatuses].flatten.include?( $?.exitstatus )
- raise ShellError.new("ERROR: '#{cmd}' failed with exit status #{$?.exitstatus}")
- end
-
- output
- end
-
- def self.current_branch
- run("git branch --no-color | grep '*' | cut -d ' ' -f 2").chomp
- end
-
- def self.remote_branch_exists?(branch)
- ! run("git branch -r --no-color | grep '#{branch}'").blank?
- end
-
- def self.ensure_clean_working_directory!
- return if run("git status", 0, 1).match(/working directory clean/)
- raise "Must have clean working directory"
- end
-
- def self.diff_staging
- run("git diff HEAD origin/staging")
- end
-
- def self.diff_production
- run("git diff origin/staging origin/production")
- end
-
- def self.push(src_branch, dst_branch)
- raise "origin/#{dst_branch} branch does not exist" unless remote_branch_exists?("origin/#{dst_branch}")
- ensure_clean_working_directory!
- begin
- run "git fetch"
- run "git push -f origin #{src_branch}:#{dst_branch}"
- rescue
- log_output(" Pushing #{src_branch} to origin/#{dst_branch} failed.", true, :bold, :red)
- raise
- end
- end
-
- def self.push_staging
- push(current_branch, "staging")
- end
-
- def self.push_production
- push("origin/staging", "production")
- end
-
- def self.branch_production(branch)
- raise "You must specify a branch name." if branch.blank?
- ensure_clean_working_directory!
- run "git fetch"
- run "git branch -f #{branch} origin/production"
- run "git checkout #{branch}"
- end
-
- def self.pull_template
- ensure_clean_working_directory!
- run "git pull git://github.com/thoughtbot/suspenders.git master"
- end
-
- private
-
- def self.log_output(string, *args)
- logging = args.shift if args.first === true
- return unless @logging || logging
- args.each do |arg|
- string = if arg.respond_to?(:call)
- arg.call(string)
- else
- string.send(arg)
- end
- end
- puts string unless string.strip.blank?
- end
-end
-
-module Git
- class Push < Thor
- desc "staging", "Reset origin's staging branch to be the current branch."
- def staging
- GitCommands.push_staging
- end
-
- desc "production", "Reset origin's production branch to origin's staging branch."
- def production
- GitCommands.push_production
- end
- end
-
- class Diff < Thor
- desc "staging", "Show the difference between current branch and origin/staging."
- def staging
- GitCommands.diff_staging
- end
-
- desc "production", "Show the difference between origin/staging and origin/production."
- def production
- GitCommands.diff_production
- end
- end
-
- class Branch < Thor
- desc "production BRANCH", "branch origin/production into BRANCH locally."
- def production(branch)
- GitCommands.branch_production(branch)
- end
- end
-end
View
75 thor.d/github.thor
@@ -1,75 +0,0 @@
-#!/usr/bin/env ruby
-
-class Github < Thor
- desc "track <user> [<branch-name>]", "track a fork belonging to <user>"
- def track(user, branch_name = nil)
- branch_name ||= user
- git %(remote add #{user} git://github.com/#{user}/#{project_name}.git)
- git %(fetch --no-tags #{user} master:refs/remotes/#{user}/master)
- git %(branch #{branch_name} --track #{user}/master)
- end
-
- desc "update", "checkout each branch that has a remote and git pull"
- def update
- all = branches
- current = all.first
- last = nil
- branches_with_remotes = all.reject { |branch| remote_for_branch(branch) == "" }
-
- branches_with_remotes.reverse.each do |branch|
- git %(checkout #{branch})
- git "pull -v --no-tags"
- last = branch
- end
-
- git %(checkout #{current}) unless last == current
- end
-
- private
-
- def command(com, capture = false)
- unless capture
- system(com)
- else
- %x(#{com}).chomp
- end
- end
-
- def git(com, capture = false)
- command("git #{com}", capture)
- end
-
- def project_name
- user_and_repo_from(remote_url("origin")).last.chomp(".git")
- end
-
- def user_and_repo_from(url)
- case url
- when %r|^git://github\.com/([^/]+/[^/]+)$|: $1.split('/')
- when %r|^(?:ssh://)?(?:git@)?github\.com:([^/]+/[^/]+)$|: $1.split('/')
- end
- end
-
- def remote_url(remote)
- git %(config --get remote.#{remote}.url), true
- end
-
- def remote_for_branch(name)
- git %(config --get branch.#{name}.remote), true
- end
-
- def remotes
- git("remote", true).split("\n")
- end
-
- # fetches list of local branches with current being first
- def branches
- git("branch", true).split("\n").inject([]) do |all, line|
- unless "*" == line[0, 1]
- all << line.strip
- else
- all.unshift line.sub(/^\*\s+/, "")
- end
- end
- end
-end
View
12 thor.d/heroku.thor
@@ -1,12 +0,0 @@
-#!/usr/bin/env ruby
-
-class Heroku < Thor
- desc "switch <email> <password>", ""
- def switch(email, password)
- `heroku keys:clear`
- path = File.join(ENV["HOME"], ".heroku", "credentials")
- string = "#{email}\n#{password}"
- File.open(path, "w") { |file| file << string }
- `heroku keys:add`
- end
-end

0 comments on commit fa7b766

Please sign in to comment.
Something went wrong with that request. Please try again.