Module: Shakapacker::Utils::GitUtils

Defined in:
lib/shakapacker/utils/git_utils.rb

Class Method Summary collapse

Class Method Details

.uncommitted_changes?(message_handler) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shakapacker/utils/git_utils.rb', line 7

def self.uncommitted_changes?(message_handler)
  return false if ENV["COVERAGE"] == "true"

  status = `git status --porcelain`
  return false if $CHILD_STATUS.success? && status.empty?

  error = if $CHILD_STATUS.success?
            "You have uncommitted code. Please commit or stash your changes before continuing"
          else
            "You do not have Git installed. Please install Git, and commit your changes before continuing"
          end
  message_handler.add_error(error)
  true
end