<commit_before>module Fastlane
  module Actions
    class GitAddAction < Action
      def self.run(params)
        should_escape = params[:shell_escape]

        if params[:pathspec]
          paths = params[:pathspec]
          UI.success("Successfully added from \"#{paths}\" 💾.")
        elsif params[:path]
          if params[:path].kind_of?(String)
            paths = shell_escape(params[:path], should_escape)
          elsif params[:path].kind_of?(Array)
            paths = params[:path].map do |p|
              shell_escape(p, should_escape)
            end.join(' ')
          end
          UI.success("Successfully added \"#{paths}\" 💾.")
        else
          paths = "."
          UI.success("Successfully added all files 💾.")
        end

        result = Actions.sh("git add #{paths}", log: FastlaneCore::Globals.verbose?).chomp
        return result
      end

      def self.shell_escape(path, should_escape)
        path = path.shellescape if should_escape
        path
      end

      #####################################################
      # @!group Documentation
      #####################################################<commit_msg>Reorder steps in git_add to display success logs only when it has been a success (#13052)<commit_after>module Fastlane
  module Actions
    class GitAddAction < Action
      def self.run(params)
        should_escape = params[:shell_escape]

        if params[:pathspec]
          paths = params[:pathspec]
          success_message = "Successfully added from \"#{paths}\" 💾."
        elsif params[:path]
          if params[:path].kind_of?(String)
            paths = shell_escape(params[:path], should_escape)
          elsif params[:path].kind_of?(Array)
            paths = params[:path].map do |p|
              shell_escape(p, should_escape)
            end.join(' ')
          end
          success_message = "Successfully added \"#{paths}\" 💾."
        else
          paths = "."
          success_message = "Successfully added all files 💾."
        end

        result = Actions.sh("git add #{paths}", log: FastlaneCore::Globals.verbose?).chomp
        UI.success(success_message)
        return result
      end

      def self.shell_escape(path, should_escape)
        path = path.shellescape if should_escape
        path
      end

      #####################################################
      # @!group Documentation
      #####################################################
{'fraction_non_alphanumeric': 0.18470301057770544, 'fraction_numerical': 0.0020341741253051262, 'mean_word_length': 2.3184885290148447, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1445493', 'n_tokens_mistral': 665, 'n_tokens_neox': 631, 'n_words': 157}