Module: Egads::Build::BuildHelpers
- Included in:
- Egads::Build
- Defined in:
- lib/egads/command/build.rb
Instance Method Summary collapse
- #can_build? ⇒ Boolean
- #error(message) ⇒ Object
- #patch_path ⇒ Object
- #sha_is_checked_out? ⇒ Boolean
- #should_build? ⇒ Boolean
- #working_directory_is_clean? ⇒ Boolean
Instance Method Details
#can_build? ⇒ Boolean
63 64 65 |
# File 'lib/egads/command/build.rb', line 63 def can_build? sha_is_checked_out? && working_directory_is_clean? end |
#error(message) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/egads/command/build.rb', line 88 def error() lines = Array() say_status :error, lines.shift, :red lines.each {|line| say_status '', line } false end |
#patch_path ⇒ Object
84 85 86 |
# File 'lib/egads/command/build.rb', line 84 def patch_path "#{sha}.patch" end |
#sha_is_checked_out? ⇒ Boolean
67 68 69 70 71 72 73 74 |
# File 'lib/egads/command/build.rb', line 67 def sha_is_checked_out? head = run_with_code("git rev-parse --verify HEAD").strip short_head = head[0,7] head == sha or error [ "Cannot build #{short_sha} because #{short_head} is checked out.", "Run `git checkout #{short_sha}` and try again" ] end |
#should_build? ⇒ Boolean
59 60 61 |
# File 'lib/egads/command/build.rb', line 59 def should_build? [:force] || !tarball.exists? end |
#working_directory_is_clean? ⇒ Boolean
76 77 78 79 80 81 82 |
# File 'lib/egads/command/build.rb', line 76 def working_directory_is_clean? run("git status -s", capture: true).empty? or error [ "Cannot build #{short_sha} because the working directory is not clean.", "Stash your changes with `git stash -u` and try again." ] end |