<commit_before>require 'tmpdir'
require 'fileutils'

class BuildpackDependencyUpdater::Dotnet < BuildpackDependencyUpdater
  def dependency_version_currently_in_manifest?
    dependencies = buildpack_manifest['dependencies']
    dependencies.select do |dep|
      dep['name'] == dependency &&
        dep['version'] == dependency_version &&
        dep['uri'] == uri
    end.count > 0
  end

  def newer_dependency_version_currently_in_manifest?
    false
  end

  def dependency_version
    @dependency_version ||= dependency_build_info['version'].gsub(/^v/, '')
  end

  def perform_dependency_update
    @removed_versions = []

    dependencies_with_same_major_minor_version = get_dependencies_with_same_major_minor_version(buildpack_manifest, dependency_version)

    previous_dependencies_with_same_major_minor_version = get_dependencies_with_same_major_minor_version(previous_buildpack_manifest, dependency_version)

    if dependencies_with_same_major_minor_version.count > 1
      version_to_delete = dependencies_with_same_major_minor_version.sort.first.to_s == previous_dependencies_with_same_major_minor_version.sort.last.to_s ? dependencies_with_same_major_minor_version.sort[1].to_s : dependencies_with_same_major_minor_version.sort.first.to_s
    else
      version_to_delete = nil
    end

    original_dependencies = buildpack_manifest["dependencies"].clone
    new_dependencies = buildpack_manifest["dependencies"].delete_if { |dep| dep["name"] == dependency && dep["version"] == version_to_delete }

    dependency_hash = {
      "name" => dependency,
      "version" => dependency_version,
      "uri" => uri,
      "sha256" => sha256,
      "cf_stacks" => ["cflinuxfs2"]
    }
    buildpack_manifest["dependencies"] << dependency_hash

    @removed_versions = (original_dependencies - new_dependencies).map { |dep| dep['version'] } unless new_dependencies == original_dependencies
  end

  def perform_dependency_specific_changes
    perform_default_versions_update<commit_msg>Do not remove old dotnet versions.<commit_after>require 'tmpdir'
require 'fileutils'

class BuildpackDependencyUpdater::Dotnet < BuildpackDependencyUpdater
  def dependency_version_currently_in_manifest?
    dependencies = buildpack_manifest['dependencies']
    dependencies.select do |dep|
      dep['name'] == dependency &&
        dep['version'] == dependency_version &&
        dep['uri'] == uri
    end.count > 0
  end

  def newer_dependency_version_currently_in_manifest?
    false
  end

  def dependency_version
    @dependency_version ||= dependency_build_info['version'].gsub(/^v/, '')
  end

  def perform_dependency_update
    @removed_versions = []

    dependency_hash = {
      "name" => dependency,
      "version" => dependency_version,
      "uri" => uri,
      "sha256" => sha256,
      "cf_stacks" => ["cflinuxfs2"]
    }
    buildpack_manifest["dependencies"] << dependency_hash
  end

  def perform_dependency_specific_changes
    perform_default_versions_update
{'fraction_non_alphanumeric': 0.09389671361502347, 'fraction_numerical': 0.006036217303822937, 'mean_word_length': 4.814814814814815, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1875377', 'n_tokens_mistral': 916, 'n_tokens_neox': 845, 'n_words': 143}