Module: Mutx::Support::ChangeInspector

Defined in:
lib/mutx/support/change_inspector.rb

Class Method Summary collapse

Class Method Details

.is_there_a_change?(data_json) ⇒ Boolean

Evaluates if code has been changed. If yes, performs a git reset hard and git pull Update commit log into Database and return true Returns true if there is a change in code. Consider true if git usage is false

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mutx/support/change_inspector.rb', line 12

def self.is_there_a_change? data_json
  if Mutx::Support::Configuration.use_git?
    if Mutx::Database::MongoConnector.last_commit != (last_repo_commit  = data_json)#(last_repo_commit  = Mutx::Support::Git.last_remote_commit)
      Mutx::Support::Log.debug "Git has been changed. Perform code update" if Mutx::Support::Log
      Mutx::Support::Git.reset_hard_and_pull
      Mutx::Database::MongoConnector.insert_commit(last_repo_commit)
      Mutx::Support::Log.debug "Commit log updated on database" if Mutx::Support::Log
      true
    else
      Mutx::Support::Log.debug "No git changes" if Mutx::Support::Log
      false
    end
  else
    true
  end
end