Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Create Kumade::Git#create

  • Loading branch information...
commit dd449f12db5761a1120f40b0ca8e9f166ce9820d 1 parent c201509
@tapajos tapajos authored
Showing with 14 additions and 10 deletions.
  1. +1 −10 lib/kumade/deployer.rb
  2. +13 −0 lib/kumade/git.rb
View
11 lib/kumade/deployer.rb
@@ -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
@@ -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
View
13 lib/kumade/git.rb
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.