Class: PerfCheck::Git
Class Method Summary collapse
- .anything_to_stash? ⇒ Boolean
- .checkout(branch, bundle = true) ⇒ Object
- .checkout_current_branch(bundle = true) ⇒ Object
- .checkout_reference(reference = 'master') ⇒ Object
- .current_branch ⇒ Object
- .pop ⇒ Object
- .stash_if_needed ⇒ Object
Class Method Details
.anything_to_stash? ⇒ Boolean
56 57 58 59 60 |
# File 'lib/perf_check/git.rb', line 56 def self.anything_to_stash? git_stash = `git diff` git_stash << `git diff --staged` !git_stash.empty? end |
.checkout(branch, bundle = true) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/perf_check/git.rb', line 23 def self.checkout(branch, bundle=true) logger.info("Checking out #{branch} and bundling... ") `git checkout #{branch} --quiet` unless $?.success? logger.fatal("Problem with git checkout! Bailing...") && abort end `git submodule update --quiet` if bundle Bundler.with_clean_env{ `bundle` } unless $?.success? logger.fatal("Problem bundling! Bailing...") && abort end end end |
.checkout_current_branch(bundle = true) ⇒ Object
19 20 21 |
# File 'lib/perf_check/git.rb', line 19 def self.checkout_current_branch(bundle=true) checkout(@current_branch, bundle) end |
.checkout_reference(reference = 'master') ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/perf_check/git.rb', line 11 def self.checkout_reference(reference='master') checkout(reference) at_exit do logger.info '' Git.checkout_current_branch(false) end end |
.current_branch ⇒ Object
7 8 9 |
# File 'lib/perf_check/git.rb', line 7 def self.current_branch @current_branch end |
.pop ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/perf_check/git.rb', line 62 def self.pop logger.info("Git stash applying...") system('git stash pop -q') unless $?.success? logger.fatal("Problem with git stash! Bailing...") && abort end end |
.stash_if_needed ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/perf_check/git.rb', line 41 def self.stash_if_needed if anything_to_stash? logger.info("Stashing your changes... ") system('git stash -q >/dev/null') unless $?.success? logger.fatal("Problem with git stash! Bailing...") && abort end at_exit do Git.pop end end end |