Class: BuildTool::VCS::GitConfiguration

Inherits:
BaseConfiguration show all
Includes:
MJ::Mixins::InheritedAttributes
Defined in:
lib/build-tool/vcs/git.rb

Overview

Configuration options for the git vcs.

Direct Known Subclasses

GitSvnConfiguration

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from BaseConfiguration

#module

Instance Method Summary collapse

Methods included from MJ::Mixins::InheritedAttributes

included

Methods inherited from BaseConfiguration

#local_path

Constructor Details

#initializeGitConfiguration

Returns a new instance of GitConfiguration.



158
159
160
161
162
163
164
165
166
# File 'lib/build-tool/vcs/git.rb', line 158

def initialize
    super
    @remote = {}
    @track = nil
    @options = {}
    @global_options = {}
    @already_checked_config = false
    @already_checked_user_config = false
end

Class Attribute Details

.global_configObject

The global configuration object



128
129
130
# File 'lib/build-tool/vcs/git.rb', line 128

def global_config
  @global_config
end

.global_config_checkedObject

Was the global configuration ($HOME/.gitconfig) already checked?



131
132
133
# File 'lib/build-tool/vcs/git.rb', line 131

def global_config_checked
  @global_config_checked
end

Instance Attribute Details

#global_optionsHash<String,String>

Returns the configured global options.

Returns:

  • (Hash<String,String>)

    the configured global options.



150
151
152
# File 'lib/build-tool/vcs/git.rb', line 150

def global_options
  @global_options
end

#nameString (readonly)

returns the name of the vcs.

Returns:

  • (String)

    the current value of name



117
118
119
# File 'lib/build-tool/vcs/git.rb', line 117

def name
  @name
end

#optionsObject

Returns the value of attribute options.



141
142
143
# File 'lib/build-tool/vcs/git.rb', line 141

def options
  @options
end

#remoteObject

Returns the value of attribute remote.



134
135
136
# File 'lib/build-tool/vcs/git.rb', line 134

def remote
  @remote
end

#trackObject



177
178
179
180
181
# File 'lib/build-tool/vcs/git.rb', line 177

def track
    return @track if @track             # Our track
    return parent.track if @parent      # Out parents track
    "origin/master"                     # The default
end

Instance Method Details

#copy_configuration(other) ⇒ Object



205
206
207
208
# File 'lib/build-tool/vcs/git.rb', line 205

def copy_configuration( other )
    super
    @remote = {}     # Do not copy the remotes
end

#merged_global_optionsObject



152
153
154
155
156
# File 'lib/build-tool/vcs/git.rb', line 152

def merged_global_options
    return @global_options if self == GitConfiguration.global_config
    return @global_options.merge( GitConfiguration.global_config.instance_variable_get( "@global_options" ) ) if  GitConfiguration.global_config
    return @global_options
end

#merged_optionsObject



142
143
144
145
146
147
# File 'lib/build-tool/vcs/git.rb', line 142

def merged_options
    return @options if self == GitConfiguration.global_config           # This is the global configuration.
    return parent.merged_options.merge( @options ) if @parent           # We have a parent. Merge with it
    return GitConfiguration.global_config.options.merge( @options ) if  GitConfiguration.global_config # No parent. Merge with global
    return @options                                                     # No parent, no global. Just us
end

#merged_remoteObject



135
136
137
138
# File 'lib/build-tool/vcs/git.rb', line 135

def merged_remote
    return parent.merged_remote.merge( @remote ) if @parent
    return @remote
end

#track_branchString

The branch part of #remote

Returns:

  • (String)

    the branch.

See Also:



197
198
199
200
201
202
203
# File 'lib/build-tool/vcs/git.rb', line 197

def track_branch
    rc = track.split('/')
    # If there is only one string we assume it is the branch name from
    # origin
    return rc[0] if rc.length == 1
    return rc[1..-1].join( '/' )
end

#track_remoteString

The remote part of #remote.

Returns:

  • (String)

    the remote.

See Also:



186
187
188
189
190
191
192
# File 'lib/build-tool/vcs/git.rb', line 186

def track_remote
    rc = track.split('/')
    # If there is only one string we assume it is the branch name from
    # origin
    return "origin" if rc.length == 1
    return rc[0]
end

#vcs(mod) ⇒ Object

Raises:

  • (StandardError)


168
169
170
171
172
# File 'lib/build-tool/vcs/git.rb', line 168

def vcs( mod )
    raise StandardError if @module and ! mod.equal?( @module )
    @module = mod
    Git.new( self )
end