Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Create Kumade::Git#create
Browse files Browse the repository at this point in the history
  • Loading branch information
tapajos committed Aug 29, 2011
1 parent c201509 commit dd449f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 1 addition & 10 deletions lib/kumade/deployer.rb
Expand Up @@ -31,9 +31,7 @@ def sync_github
end

def sync_heroku
unless branch_exist?(DEPLOY_BRANCH)
run_or_error("git branch deploy", "Failed to create #{DEPLOY_BRANCH}")
end
@git.create(DEPLOY_BRANCH)
@git.push("#{DEPLOY_BRANCH}:master", environment, true)
end

Expand Down Expand Up @@ -173,13 +171,6 @@ def run(command, config = {})
config[:capture] ? `#{command}` : system("#{command}")
end

def branch_exist?(branch)
branches = `git branch`
regex = Regexp.new('[\\n\\s\\*]+' + Regexp.escape(branch.to_s) + '\\n')
result = ((branches =~ regex) ? true : false)
return result
end

def error(message)
say("==> ! #{message}", :red)
exit 1
Expand Down
13 changes: 13 additions & 0 deletions lib/kumade/git.rb
Expand Up @@ -16,6 +16,12 @@ def push(branch, remote = 'origin', force = false)
success("Pushed #{branch} -> #{remote}")
end

def create(branch)
unless branch_exist?(branch)
run_or_error("git branch #{branch}", "Failed to create #{branch}")
end
end

def run_or_error(commands, error_message)
all_commands = [commands].flatten.join(' && ')
if @pretending
Expand All @@ -38,5 +44,12 @@ def error(message)
def success(message)
say("==> #{message}", :green)
end

def branch_exist?(branch)
branches = `git branch`
regex = Regexp.new('[\\n\\s\\*]+' + Regexp.escape(branch.to_s) + '\\n')
result = ((branches =~ regex) ? true : false)
return result
end
end
end

0 comments on commit dd449f1

Please sign in to comment.