Module: Egads::Build::BuildHelpers

Included in:
Egads::Build
Defined in:
lib/egads/command/build.rb

Instance Method Summary collapse

Instance Method Details

#can_build?Boolean

Returns:

  • (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(message)
  lines = Array(message)
  say_status :error, lines.shift, :red
  lines.each {|line| say_status '', line }

  false
end

#patch_pathObject



84
85
86
# File 'lib/egads/command/build.rb', line 84

def patch_path
  "#{sha}.patch"
end

#sha_is_checked_out?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


59
60
61
# File 'lib/egads/command/build.rb', line 59

def should_build?
  options[:force] || !tarball.exists?
end

#working_directory_is_clean?Boolean

Returns:

  • (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