Module: BbDeploy::Git
- Defined in:
- lib/bb_deploy/git.rb
Class Method Summary collapse
-
.check_git_status! ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
-
.current_branch(reload = false) ⇒ Object
NOTE - THE DEFAULT AUTO-MEMOIZATION CAN CAUSE ISSUES IF YOU FORGET IT’S HAPPENING, SO NOTE THAT IT OCCURS!!!.
- .local_release(branch_name) ⇒ Object
- .migrations_present?(sha) ⇒ Boolean
- .on_a_release_branch? ⇒ Boolean
- .on_master? ⇒ Boolean
- .push_to_phase(phase) ⇒ Object
- .remote_release(branch_name) ⇒ Object
Class Method Details
.check_git_status! ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bb_deploy/git.rb', line 31 def check_git_status! # rubocop:disable Metrics/CyclomaticComplexity puts "Running `git fetch` ... " quietly { `git fetch` } if `git log ..origin/#{current_branch}`.present? exit(0) unless BbDeploy::Task.ask("There are new commits on the remote branch 'origin/#{current_branch}'. Are you sure you want to proceed?") end status_msg_a = `git status`.split(/(?:\n+)/) if status_msg_a[1] =~ /your.branch.is.ahead/i exit(0) unless BbDeploy::Task.ask("You have local, committed changes that have not been pushed to the remote. Are you sure you want to proceed?") end unless status_msg_a.last =~ /nothing to commit/i exit(0) unless BbDeploy::Task.ask("You have local, uncommitted changes. Are you sure you want to proceed?") end end |
.current_branch(reload = false) ⇒ Object
NOTE - THE DEFAULT AUTO-MEMOIZATION CAN CAUSE ISSUES IF YOU FORGET IT’S HAPPENING, SO NOTE THAT IT OCCURS!!!
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bb_deploy/git.rb', line 6 def current_branch(reload = false) if reload || !@current_branch # I don't know sed at all, hence I don't know which backslashes need to be doubled and which don't :( cmd = 'git branch 2> /dev/null | sed -e \'/^[^*]/d\' -e \'s/* \(.*\)/\1/\'' result = `#{cmd}` raise "Unable to determine the current branch name" if result.blank? @current_branch = result.strip else @current_branch end end |
.local_release(branch_name) ⇒ Object
50 51 52 |
# File 'lib/bb_deploy/git.rb', line 50 def local_release(branch_name) `git branch --list "#{branch_name}"` end |
.migrations_present?(sha) ⇒ Boolean
46 47 48 |
# File 'lib/bb_deploy/git.rb', line 46 def migrations_present?(sha) `git diff #{sha} db/migrate`.present? end |
.on_a_release_branch? ⇒ Boolean
27 28 29 |
# File 'lib/bb_deploy/git.rb', line 27 def on_a_release_branch? current_branch.start_with?('release_') end |
.on_master? ⇒ Boolean
23 24 25 |
# File 'lib/bb_deploy/git.rb', line 23 def on_master? current_branch == 'master' end |
.push_to_phase(phase) ⇒ Object
18 19 20 21 |
# File 'lib/bb_deploy/git.rb', line 18 def push_to_phase(phase) puts "git push #{phase} HEAD:master --force" # `git push #{phase} HEAD:master --force` end |
.remote_release(branch_name) ⇒ Object
54 55 56 |
# File 'lib/bb_deploy/git.rb', line 54 def remote_release(branch_name) `git branch -r --list "origin/#{branch_name}"` end |