Module: ReactOnRails::GitUtils

Defined in:
lib/react_on_rails/git_utils.rb

Class Method Summary collapse

Class Method Details

.uncommitted_changes?(message_handler, git_installed: true) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  status = `git status --porcelain`
  return false if git_installed && status&.empty?

  error = if git_installed
            "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