Class: Kaiser::Plugins::GitSubmodule

Inherits:
Kaiser::Plugin show all
Defined in:
lib/kaiser/plugins/git_submodule.rb

Instance Method Summary collapse

Methods inherited from Kaiser::Plugin

all_plugins, inherited, #initialize, loaded?, #method_missing

Constructor Details

This class inherits a constructor from Kaiser::Plugin

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kaiser::Plugin

Instance Method Details

#on_initObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kaiser/plugins/git_submodule.rb', line 6

def on_init
  `git submodule status`.lines.each do |line|
    # The git-submodule man page says uninitialized submodules are prefixed with a -
    # but I found this unreliable. While testing I pressed Control-C in the middle of
    # the update command so some submodule would be initialized and others wouldn't.
    # After that, the status command had removed the - for every submodule.
    # Therefore we just check if there's files in the directory instead.
    dir = line.strip.split(' ')[1]
    if !Dir.exist?(dir) || Dir.empty?(dir) # rubocop:disable Style/Next
      puts "Found uninitialized git submodule '#{dir}'"
      puts "please run 'git submodule update --init --recursive'"
      exit 1
    end
  end
end