# File lib/bundler/source.rb, line 489 489: def self.from_lock(options) 490: new(options.merge("uri" => options.delete("remote"))) 491: end
# File lib/bundler/source.rb, line 476 476: def initialize(options) 477: super 478: 479: # stringify options that could be set as symbols 480: %(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] } 481: 482: @uri = options["uri"] 483: @ref = options["ref"] || options["branch"] || options["tag"] || 'master' 484: @revision = options["revision"] 485: @submodules = options["submodules"] 486: @update = false 487: end
# File lib/bundler/source.rb, line 504 504: def eql?(o) 505: Git === o && 506: uri == o.uri && 507: ref == o.ref && 508: name == o.name && 509: version == o.version && 510: submodules == o.submodules 511: end
# File lib/bundler/source.rb, line 551 551: def install(spec) 552: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " 553: 554: unless @installed 555: Bundler.ui.debug " * Checking out revision: #{ref}" 556: checkout if allow_git_ops? 557: @installed = true 558: end 559: generate_bin(spec) 560: end
# File lib/bundler/source.rb, line 562 562: def load_spec_files 563: super 564: rescue PathError, GitError 565: raise GitError, "#{to_s} is not checked out. Please run `bundle install`" 566: end
# File lib/bundler/source.rb, line 520 520: def name 521: File.basename(@uri, '.git') 522: end
# File lib/bundler/source.rb, line 524 524: def path 525: @install_path ||= begin 526: git_scope = "#{base_name}-#{shortref_for_path(revision)}" 527: 528: if Bundler.requires_sudo? 529: Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) 530: else 531: Bundler.install_path.join(git_scope) 532: end 533: end 534: end
TODO: actually cache git specs
# File lib/bundler/source.rb, line 541 541: def specs 542: if allow_git_ops? && !@update 543: # Start by making sure the git cache is up to date 544: cache 545: checkout 546: @update = true 547: end 548: local_specs 549: end
# File lib/bundler/source.rb, line 493 493: def to_lock 494: out = "GIT\n" 495: out << " remote: #{@uri}\n" 496: out << " revision: #{revision}\n" 497: %(ref branch tag submodules).each do |opt| 498: out << " #{opt}: #{options[opt]}\n" if options[opt] 499: end 500: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB 501: out << " specs:\n" 502: end
# File lib/bundler/source.rb, line 676 676: def allow_git_ops? 677: @allow_remote || @allow_cached 678: end
# File lib/bundler/source.rb, line 587 587: def base_name 588: File.basename(uri.sub(%{^(\w+://)?([^/:]+:)},''), ".git") 589: end
# File lib/bundler/source.rb, line 636 636: def cache 637: if cached? 638: return if has_revision_cached? 639: Bundler.ui.info "Updating #{uri}" 640: in_cache do 641: git %fetch --force --quiet --tags #{uri_escaped} "refs/heads/*:refs/heads/*"| 642: end 643: else 644: Bundler.ui.info "Fetching #{uri}" 645: FileUtils.mkdir_p(cache_path.dirname) 646: git %clone #{uri_escaped} "#{cache_path}" --bare --no-hardlinks| 647: end 648: end
# File lib/bundler/source.rb, line 624 624: def cache_path 625: @cache_path ||= begin 626: git_scope = "#{base_name}-#{uri_hash}" 627: 628: if Bundler.requires_sudo? 629: Bundler.user_bundle_path.join("cache/git", git_scope) 630: else 631: Bundler.cache.join("git", git_scope) 632: end 633: end 634: end
# File lib/bundler/source.rb, line 690 690: def cached? 691: cache_path.exist? 692: end
# File lib/bundler/source.rb, line 650 650: def checkout 651: unless File.exist?(path.join(".git")) 652: FileUtils.mkdir_p(path.dirname) 653: FileUtils.rm_rf(path) 654: git %clone --no-checkout "#{cache_path}" "#{path}"| 655: File.chmod((0777 & ~File.umask), path) 656: end 657: Dir.chdir(path) do 658: git %fetch --force --quiet --tags "#{cache_path}"| 659: git "reset --hard #{revision}" 660: 661: if @submodules 662: git "submodule init" 663: git "submodule update" 664: end 665: end 666: end
# File lib/bundler/source.rb, line 570 570: def git(command) 571: if allow_git_ops? 572: out = %{git #{command}} 573: 574: if $?.exitstatus != 0 575: msg = "Git error: command `git #{command}` in directory #{Dir.pwd} has failed." 576: msg << "\nIf this error persists you could try removing the cache directory '#{cache_path}'" if cached? 577: raise GitError, msg 578: end 579: out 580: else 581: raise GitError, "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, " "this error message could probably be more useful. Please submit a ticket at http://github.com/carlhuda/bundler/issues " "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}" 582: end 583: end
# File lib/bundler/source.rb, line 668 668: def has_revision_cached? 669: return unless @revision 670: in_cache { git %cat-file -e #{@revision}| } 671: true 672: rescue GitError 673: false 674: end
# File lib/bundler/source.rb, line 694 694: def in_cache(&blk) 695: cache unless cached? 696: Dir.chdir(cache_path, &blk) 697: end
# File lib/bundler/source.rb, line 680 680: def revision 681: @revision ||= begin 682: if allow_git_ops? 683: in_cache { git("rev-parse #{ref}").strip } 684: else 685: raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application" 686: end 687: end 688: end
# File lib/bundler/source.rb, line 591 591: def shortref_for_display(ref) 592: ref[0..6] 593: end
# File lib/bundler/source.rb, line 595 595: def shortref_for_path(ref) 596: ref[0..11] 597: end
Escape the URI for git commands
# File lib/bundler/source.rb, line 612 612: def uri_escaped 613: if Bundler::WINDOWS 614: # Windows quoting requires double quotes only, with double quotes 615: # inside the string escaped by being doubled. 616: '"' + uri.gsub('"') {|s| '""'} + '"' 617: else 618: # Bash requires single quoted strings, with the single quotes escaped 619: # by ending the string, escaping the quote, and restarting the string. 620: "'" + uri.gsub("'") {|s| "'\\''"} + "'" 621: end 622: end
# File lib/bundler/source.rb, line 599 599: def uri_hash 600: if uri =~ %{^\w+://(\w+@)?} 601: # Downcase the domain component of the URI 602: # and strip off a trailing slash, if one is present 603: input = URI.parse(uri).normalize.to_s.sub(%{/$},'') 604: else 605: # If there is no URI scheme, assume it is an ssh/git URI 606: input = uri 607: end 608: Digest::SHA1.hexdigest(input) 609: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.