Class: Bundler::GitSource
- Inherits:
-
DirectorySource
- Object
- Source
- DirectorySource
- Bundler::GitSource
- Defined in:
- lib/bundler/source.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes inherited from DirectorySource
Attributes inherited from Source
Instance Method Summary collapse
- #download(spec) ⇒ Object
- #gems ⇒ Object
-
#initialize(options) ⇒ GitSource
constructor
A new instance of GitSource.
- #location ⇒ Object
Methods inherited from DirectorySource
#==, #add_spec, #can_be_local?, #locate_gemspecs, #merge_defined_specs, #to_s, #validate_gemspec
Constructor Details
#initialize(options) ⇒ GitSource
288 289 290 291 292 293 294 |
# File 'lib/bundler/source.rb', line 288 def initialize() super @uri = [:uri] @ref = [:ref] @branch = [:branch] @shallow = [:shallow] ? '--depth=1' : '' end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
286 287 288 |
# File 'lib/bundler/source.rb', line 286 def branch @branch end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
286 287 288 |
# File 'lib/bundler/source.rb', line 286 def ref @ref end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
286 287 288 |
# File 'lib/bundler/source.rb', line 286 def uri @uri end |
Instance Method Details
#download(spec) ⇒ Object
323 324 325 |
# File 'lib/bundler/source.rb', line 323 def download(spec) # Nothing needed here end |
#gems ⇒ Object
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/bundler/source.rb', line 301 def gems unless location.directory? # Raise an error if the source should run in local mode, # but it has not been cached yet. if local raise SourceNotCached, "Git repository '#{@uri}' has not been cloned yet" end FileUtils.mkdir_p(location.dirname) Bundler.logger.info "Cloning git repository at: #{@uri}" `git clone #{@shallow} #{@uri} #{location} --no-hardlinks` if @ref Dir.chdir(location) { `git checkout --quiet #{@ref}` } elsif @branch && @branch != "master" Dir.chdir(location) { `git checkout --quiet origin/#{@branch}` } end end super end |
#location ⇒ Object
296 297 298 299 |
# File 'lib/bundler/source.rb', line 296 def location # TMP HAX to get the *.gemspec reading to work repository.path.join('dirs', File.basename(@uri, '.git')) end |