lib/teapot/command/fetch.rb in teapot-2.0.0.pre.rc1 vs lib/teapot/command/fetch.rb in teapot-2.0.0.pre.rc2

- old
+ new

@@ -34,10 +34,12 @@ options do option '--update', "Update dependencies to the latest versions." option '--local', "Don't update from source, assume updated local packages." end + many :packages, "Only update the specified packages, or all packages if none specified." + def invoke(parent) logger = parent.logger context = parent.context resolved = Set.new @@ -45,13 +47,16 @@ unresolved = context.unresolved(configuration.packages) while true configuration.packages.each do |package| next if resolved.include? package - - fetch_package(context, configuration, package, logger, **@options) - + + # If specific packages were listed, limit updates to them. + if @packages.empty? || @packages.include?(package.name) + fetch_package(context, configuration, package, logger, **@options) + end + # We are done with this package, don't try to process it again: resolved << package end # Resolve any/all imports: @@ -102,11 +107,11 @@ destination_path.make_symlink(local_path) end end def clone_or_pull_package(context, configuration, package, package_lock, logger) - logger.info "Fetching #{package}...".color(:cyan) + logger.info "Processing #{package}...".color(:cyan) # Where we are going to put the package: destination_path = package.path base_uri = URI(package.options[:source].to_s) @@ -123,29 +128,20 @@ branch = package_lock[:branch] end commit = package_lock ? package_lock[:commit] : nil - unless destination_path.exist? - logger.info "Cloning package at path #{destination_path} ...".color(:cyan) - - begin - external_url = package.external_url(context.root) - - repository = Rugged::Repository.clone_at(external_url.to_s, destination_path.to_s, checkout_branch: branch) - repository.checkout(commit) if commit - # Repository.new().clone!(external_url, branch, commit) - rescue - logger.info "Failed to clone #{external_url}...".color(:red) + if destination_path.exist? + logger.info "Updating package at path #{destination_path}...".color(:cyan) - raise - end + repository = Rugged::Repository.new(destination_path.to_s) + repository.checkout(commit || 'origin/master') else - logger.info "Updating package at path #{destination_path} ...".color(:cyan) - - commit = package_lock ? package_lock[:commit] : nil - Rugged::Repository.new(destination_path.to_s).checkout(commit) - # Repository.new(destination_path).update(branch, commit) + logger.info "Cloning package at path #{destination_path}...".color(:cyan) + + external_url = package.external_url(context.root) + repository = Rugged::Repository.clone_at(external_url.to_s, destination_path.to_s, checkout_branch: branch) + repository.checkout(commit) if commit end end def fetch_package(context, configuration, package, logger, update: false, local: false) if package.local?