Created
March 30, 2012 22:32
-
-
Save rondy/2256526 to your computer and use it in GitHub Desktop.
Revisions
-
rondy revised this gist
May 19, 2012 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def ask end def invalid_branch?(branch) !git_branch.exists? branch end def git_branch @@ -42,6 +42,10 @@ def all branches.collect(&removing_asterisk_from_current_branch) end def exists?(branch) branches.include? branch end private # => ["* master", "feature_1"] @@ -52,4 +56,4 @@ def branches def removing_asterisk_from_current_branch lambda { |branch| branch.gsub(/^\* /,"") } end end -
rondy revised this gist
May 19, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ end def prompt_branch_name BranchedDeploy.new.prompt end class BranchedDeploy def prompt begin branch = ask -
rondy created this gist
Mar 30, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ namespace :deploy do task :set_branch do set :branch, prompt_branch_name end before "deploy:update" , "deploy:set_branch" end def prompt_branch_name DeployBranchName.new.prompt end class DeployBranchName def prompt begin branch = ask end while invalid_branch? branch branch end private # => * Type branch name to deploy: (master, feature_1) |master| def ask Capistrano::CLI.ui.ask(" * Type branch name to deploy (#{git_branch.all.join(', ')}):") { |q| q.default = git_branch.current } end def invalid_branch?(branch) !git_branch.all.include? branch end def git_branch @git_branch ||= GitBranch.new end end class GitBranch def current branches.detect { |branch| branch.start_with? "*" }[2..-1] end def all branches.collect(&removing_asterisk_from_current_branch) end private # => ["* master", "feature_1"] def branches @branches ||= `git branch`.split("\n").map(&:strip) end def removing_asterisk_from_current_branch lambda { |branch| branch.gsub(/^\* /,"") } end end