Class: R10K::Environment::Git

Inherits:
Base
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/environment/git.rb

Overview

This class implements an environment based on a Git branch.

Since:

  • 1.3.0

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Base

#basedir, #dirname, #name, #path, #puppetfile

Instance Method Summary collapse

Methods included from Logging

formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level

Methods inherited from Base

#accept, #modules

Constructor Details

#initialize(name, basedir, dirname, options = {}) ⇒ Git

Initialize the given SVN environment.

Parameters:

  • name (String)

    The unique name describing this environment.

  • basedir (String)

    The base directory where this environment will be created.

  • dirname (String)

    The directory name for this environment.

  • options (Hash) (defaults to: {})

    An additional set of options for this environment.

  • options (String) (defaults to: {})

    :remote The URL to the remote git repository

  • options (String) (defaults to: {})

    :ref The git reference to use for this environment

Since:

  • 1.3.0



34
35
36
37
38
39
40
# File 'lib/r10k/environment/git.rb', line 34

def initialize(name, basedir, dirname, options = {})
  super
  @remote = options[:remote]
  @ref    = options[:ref]

  @working_dir = R10K::Git::WorkingDir.new(@ref, @remote, @basedir, @dirname)
end

Instance Attribute Details

#refObject (readonly)

Since:

  • 1.3.0



18
19
20
# File 'lib/r10k/environment/git.rb', line 18

def ref
  @ref
end

#remoteObject (readonly)

Since:

  • 1.3.0



14
15
16
# File 'lib/r10k/environment/git.rb', line 14

def remote
  @remote
end

#working_dirObject (readonly)

Since:

  • 1.3.0



23
24
25
# File 'lib/r10k/environment/git.rb', line 23

def working_dir
  @working_dir
end

Instance Method Details

#statusObject

Since:

  • 1.3.0



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/r10k/environment/git.rb', line 54

def status
  if !@working_dir.exist?
    :absent
  elsif !@working_dir.git?
    :mismatched
  elsif !(@remote == @working_dir.remote)
    :mismatched
  elsif !@synced
    :outdated
  else
    :insync
  end
end

#syncvoid

This method returns an undefined value.

Clone or update the given Git environment.

If the environment is being created for the first time, it will automatically update all modules to ensure that the environment is complete.

Since:

  • 1.3.0



49
50
51
52
# File 'lib/r10k/environment/git.rb', line 49

def sync
  @working_dir.sync
  @synced = true
end

#sync_modulesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.

Since:

  • 1.3.0



70
71
72
73
74
75
# File 'lib/r10k/environment/git.rb', line 70

def sync_modules
  modules.each do |mod|
    logger.debug "Deploying module #{mod.name}"
    mod.sync
  end
end