Module: Karo::Common
Instance Method Summary collapse
- #branch_exists?(name) ⇒ Boolean
- #checkout_branch(name) ⇒ Object
- #create_and_checkout_branch(name) ⇒ Object
- #create_branch(name) ⇒ Object
- #current_branch ⇒ Object
- #git_repo ⇒ Object
- #make_command(configuration, namespace, command, extras) ⇒ Object
- #run_it(cmd, verbose = false) ⇒ Object
Instance Method Details
#branch_exists?(name) ⇒ Boolean
31 32 33 |
# File 'lib/karo/common.rb', line 31 def branch_exists?(name) git_repo.branches.find { |b| b.name.start_with?(name) } end |
#checkout_branch(name) ⇒ Object
39 40 41 |
# File 'lib/karo/common.rb', line 39 def checkout_branch(name) run_it "git checkout #{name}", [:verbose] end |
#create_and_checkout_branch(name) ⇒ Object
47 48 49 50 |
# File 'lib/karo/common.rb', line 47 def create_and_checkout_branch(name) create_branch name checkout_branch name end |
#create_branch(name) ⇒ Object
35 36 37 |
# File 'lib/karo/common.rb', line 35 def create_branch(name) run_it "git branch #{name}", [:verbose] end |
#current_branch ⇒ Object
43 44 45 |
# File 'lib/karo/common.rb', line 43 def current_branch git_repo.head.name end |
#git_repo ⇒ Object
27 28 29 |
# File 'lib/karo/common.rb', line 27 def git_repo Rugged::Repository.new(".") end |
#make_command(configuration, namespace, command, extras) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/karo/common.rb', line 10 def make_command(configuration, namespace, command, extras) commands = configuration["commands"] if commands && commands[namespace] && commands[namespace][command] command = commands[namespace][command] end extras = extras.flatten(1).uniq.join(" ").strip "#{command} #{extras}" end |
#run_it(cmd, verbose = false) ⇒ Object
22 23 24 25 |
# File 'lib/karo/common.rb', line 22 def run_it(cmd, verbose=false) say cmd, :green if verbose system cmd unless [:dryrun] end |