Class: Overcommit::Hook::PostCheckout::SubmoduleStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook/post_checkout/submodule_status.rb

Overview

Checks the status of submodules in the current repository and notifies the user if any are uninitialized, out of date with the current index, or contain merge conflicts.

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #initialize, #name, #process_hook_return_value, #quiet?, #required?, #required_executable, #required_libraries, #run?, #run_and_transform, #skip?

Constructor Details

This class inherits a constructor from Overcommit::Hook::Base

Instance Method Details

#runObject



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

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