Module: Egads::Build::BuildHelpers

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

Instance Method Summary collapse

Instance Method Details

#build_typeObject



109
110
111
# File 'lib/egads/command/build.rb', line 109

def build_type
  options[:seed] ? 'seed' : 'patch'
end

#can_build?Boolean

Returns:

  • (Boolean)


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

def can_build?
  sha_is_checked_out? && working_directory_is_clean?
end

#error(message) ⇒ Object



113
114
115
116
117
118
119
# File 'lib/egads/command/build.rb', line 113

def error(message)
  lines = Array(message)
  say_status :error, lines.shift, :red
  lines.each {|line| say_status '', line }

  false
end

#patch_pathObject



105
106
107
# File 'lib/egads/command/build.rb', line 105

def patch_path
  "#{sha}.patch"
end

#sha_is_checked_out?Boolean

Returns:

  • (Boolean)


88
89
90
91
92
93
94
95
# File 'lib/egads/command/build.rb', line 88

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)


80
81
82
# File 'lib/egads/command/build.rb', line 80

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

#working_directory_is_clean?Boolean

Returns:

  • (Boolean)


97
98
99
100
101
102
103
# File 'lib/egads/command/build.rb', line 97

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