Module: Overcommit::Hook::Shared::SubmoduleStatus

Included in:
PostCheckout::SubmoduleStatus, PostCommit::SubmoduleStatus, PostMerge::SubmoduleStatus, PostRewrite::SubmoduleStatus
Defined in:
lib/overcommit/hook/shared/submodule_status.rb

Overview

Shared code used by all ‘SubmoduleStatus` hooks to notify the user if any submodules are uninitialized, out of date with the current index, or contain merge conflicts.

Instance Method Summary collapse

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/overcommit/hook/shared/submodule_status.rb', line 8

def run
  messages = []
  submodule_statuses.each do |submodule_status|
    path = submodule_status.path
    if submodule_status.uninitialized?
      messages << "Submodule #{path} is uninitialized."
    elsif submodule_status.outdated?
      messages << "Submodule #{path} is out of date with the current index."
    elsif submodule_status.merge_conflict?
      messages << "Submodule #{path} has merge conflicts."
    end
  end

  return :pass if messages.empty?

  [:warn, messages.join("\n")]
end