<commit_before>module Capistrano
  module Middleman
    module Utils
      def zip(
        source_directory,
        destination_file,
        prefix: nil,
        working_directory: Dir.getwd,
        exclude_patterns: [],
        keep_filesystem_permissions: false,
        file_permissions: 0664,
        directory_permissions: 2775
      )
        list = Rake::FileList.new(File.join(source_directory, '**', '*'))
        list.exclude { |f| !File.file? f }
        exclude_patterns.each { |e| list.exclude e }

        Zip::File.open(destination_file, Zip::File::CREATE) do |z|
          list.each do |filename|
            paths = []
            paths << Pathname.new(prefix) unless prefix.nil? || prefix.empty?
            paths << Pathname.new(filename).relative_path_from(Pathname.new(working_directory))

            z.add(File.join(*paths), File.expand_path(filename))

            next if keep_filesystem_permissions

            z.file.chmod(file_permissions , File.join(*paths)) if z.file.file? File.join(*paths)
            z.file.chmod(directory_permissions, File.join(*paths)) if z.file.directory? File.join(*paths)
          end
        end
      end

      module_function :zip
    end
  end
end
<commit_msg>Do not add again<commit_after>module Capistrano
  module Middleman
    module Utils
      def zip(
        source_directory,
        destination_file,
        prefix: nil,
        working_directory: Dir.getwd,
        exclude_patterns: [],
        keep_filesystem_permissions: false,
        file_permissions: 0664,
        directory_permissions: 2775
      )
        list = Rake::FileList.new(File.join(source_directory, '**', '*'))
        list.exclude { |f| !File.file? f }
        exclude_patterns.each { |e| list.exclude e }

        Zip::File.open(destination_file, Zip::File::CREATE) do |z|
          list.uniq.each do |filename|
            paths = []
            paths << Pathname.new(prefix) unless prefix.nil? || prefix.empty?
            paths << Pathname.new(filename).relative_path_from(Pathname.new(working_directory))

            next if z.file.exist? File.join(*paths)

            z.add(File.join(*paths), File.expand_path(filename))

            next if keep_filesystem_permissions

            z.file.chmod(file_permissions , File.join(*paths)) if z.file.file? File.join(*paths)
            z.file.chmod(directory_permissions, File.join(*paths)) if z.file.directory? File.join(*paths)
          end
        end
      end

      module_function :zip
    end
  end
end

{'fraction_non_alphanumeric': 0.1121272365805169, 'fraction_numerical': 0.006361829025844931, 'mean_word_length': 2.3501997336884153, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '501969', 'n_tokens_mistral': 778, 'n_tokens_neox': 744, 'n_words': 145}