lib/rbs/collection/config/lockfile_generator.rb in rbs-3.0.4 vs lib/rbs/collection/config/lockfile_generator.rb in rbs-3.1.0

- old
+ new

@@ -74,11 +74,11 @@ if dep.autorequire && dep.autorequire.empty? next end if spec = gem_hash[dep.name] - assign_gem(name: dep.name, version: spec.version, ignored_gems: ignored_gems, src_data: nil) + assign_gem(name: dep.name, version: spec.version, ignored_gems: ignored_gems, src_data: nil, skip: dep.source.is_a?(Bundler::Source::Gemspec)) end end lockfile.lockfile_path.write(YAML.dump(lockfile.to_lockfile)) end @@ -89,46 +89,48 @@ unless lock.gemfile_lock_fullpath == gemfile_lock_path raise GemfileLockMismatchError.new(expected: lock.gemfile_lock_fullpath, actual: gemfile_lock_path) end end - private def assign_gem(name:, version:, src_data:, ignored_gems:) + private def assign_gem(name:, version:, src_data:, ignored_gems:, skip: false) return if ignored_gems.include?(name) return if lockfile.gems.key?(name) - # @type var locked: Lockfile::library? + unless skip + # @type var locked: Lockfile::library? - if existing_lockfile - locked = existing_lockfile.gems[name] - end + if existing_lockfile + locked = existing_lockfile.gems[name] + end - # If rbs_collection.lock.yaml contain the gem, use it. - # Else find the gem from gem_collection. - unless locked - source = - if src_data - Sources.from_config_entry(src_data, base_directory: config.config_path.dirname) - else - find_source(name: name) - end + # If rbs_collection.lock.yaml contain the gem, use it. + # Else find the gem from gem_collection. + unless locked + source = + if src_data + Sources.from_config_entry(src_data, base_directory: config.config_path.dirname) + else + find_source(name: name) + end - if source - installed_version = version - best_version = find_best_version(version: installed_version, versions: source.versions(name)) + if source + installed_version = version + best_version = find_best_version(version: installed_version, versions: source.versions(name)) - locked = { - name: name, - version: best_version.to_s, - source: source, - } + locked = { + name: name, + version: best_version.to_s, + source: source, + } + end end - end - if locked - lockfile.gems[name] = locked + if locked + lockfile.gems[name] = locked - locked[:source].dependencies_of(locked[:name], locked[:version])&.each do |dep| - assign_stdlib(name: dep["name"], from_gem: name) + locked[:source].dependencies_of(locked[:name], locked[:version])&.each do |dep| + assign_stdlib(name: dep["name"], from_gem: name) + end end end gem_hash[name].dependencies.each do |dep| if spec = gem_hash[dep.name]