<commit_before>require "svn_command_helper/version"
require 'pathname'
require 'yaml'
require 'time'
require 'tmpdir'
require 'ostruct'
require 'rexml/document'
require "system_command_helper"

# Subversion command helper
module SvnCommandHelper
  # Subversion native command and some utilities
  module Svn
    # module methods
    class << self
      include ::SystemCommandHelper

      # svn commit
      # @param [String] message commit message
      # @param [path string like] path target path
      def commit(message, path = ".")
        if cap("svn status #{path}").empty?
          sys "svn revert -R #{path}"
          puts "[WARNING] no change: #{message}"
        else
          sys "svn commit -m '#{message}' #{path}"
        end
        sys "svn update #{path}"
      end

      # svn list
      # @param [uri string like] uri target uri
      # @param [Boolean] recursive --recursive
      # @return [Array<String>] paths
      def list(uri, recursive = false)
        cap("svn list #{recursive ? '-R' : ''} #{uri}").split(/\n/).compact
          .reject {|path| path.empty?}
      end

      # svn list --recursive
      # @param [uri string like] uri target uri
      # @return [Array<String>] paths
      def list_recursive(uri)
        list(uri, true)
      end

      # svn list -> grep only files
      # @param [uri string like] uri target uri
      # @param [Boolean] recursive --recursive
      # @return [Array<String>] file paths
      def list_files(uri, recursive = false)
        list(uri, recursive).reject {|path| path.end_with?("/")} # dir
      end

      # svn list --recursive -> grep only files
      # @param [uri string like] uri target uri
      # @return [Array<String>] file paths
      def list_files_recursive(uri)
        list_files(uri, true)
      end<commit_msg>list_cache<commit_after>require "svn_command_helper/version"
require 'pathname'
require 'yaml'
require 'time'
require 'tmpdir'
require 'ostruct'
require 'rexml/document'
require "system_command_helper"

# Subversion command helper
module SvnCommandHelper
  # Subversion native command and some utilities
  module Svn
    # module methods
    class << self
      include ::SystemCommandHelper

      # svn commit
      # @param [String] message commit message
      # @param [path string like] path target path
      def commit(message, path = ".")
        if cap("svn status #{path}").empty?
          sys "svn revert -R #{path}"
          puts "[WARNING] no change: #{message}"
        else
          sys "svn commit -m '#{message}' #{path}"
        end
        sys "svn update #{path}"
      end

      # svn list
      # @param [uri string like] uri target uri
      # @param [Boolean] recursive --recursive
      # @return [Array<String>] paths
      def list(uri, recursive = false)
        if @list_cache && @list_cache[uri]
          @list_cache[uri]
        else
          list = cap("svn list #{recursive ? '-R' : ''} #{uri}").split(/\n/).compact
            .reject {|path| path.empty?}
          @list_cache[uri] = list if @list_cache
          list
        end
      end

      # svn list --recursive
      # @param [uri string like] uri target uri
      # @return [Array<String>] paths
      def list_recursive(uri)
        list(uri, true)
      end

      # svn list -> grep only files
      # @param [uri string like] uri target uri
      # @param [Boolean] recursive --recursive
      # @return [Array<String>] file paths
      def list_files(uri, recursive = false)
        list(uri, recursive).reject {|path| path.end_with?("/")} # dir
      end

      # svn list --recursive -> grep only files
      # @param [uri string like] uri target uri
      # @return [Array<String>] file paths
      def list_files_recursive(uri)
        list_files(uri, true)
      end

      # svn list cache block
      def list_cache(&block)
        @list_cache = {}
        block.call
        @list_cache = nil
      end
{'fraction_non_alphanumeric': 0.11450381679389313, 'fraction_numerical': 0.0, 'mean_word_length': 2.3229078613693996, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6405667', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1144, 'n_words': 378}