<commit_before>module Fastlane
  module Actions
    class GetVersionNumberFromGitBranchAction < Action
      def self.run(params)
        if Helper.test?
          branch = 'releases/release-1.3.5'
        else
          branch = GitBranchAction.run
        end

        pattern = params[:pattern].dup
        pattern["#"] = "(.*)"

        match = Regexp.new(pattern).match(branch)
        UI.user_error!("Cannot find version number in git branch '#{branch}' by pattern '#{params[:pattern]}'") unless match
        match[1]
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Extract version number from git branch name"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :pattern,
                             env_name: "FL_VERSION_NUMBER_FROM_GIT_BRANCH_PATTERN",
                             description: "Pattern for branch name, should contain # character in place of version number",
                             default_value: 'release-#',
                             is_string: true)
        ]
      end

      def self.authors
        ["SiarheiFedartsou"]
      end

      def self.is_supported?(platform)
        [:ios, :mac].include? platform
      end
    end
  end
end
<commit_msg>Issue #3 fixed: `get_version_number_from_git_branch` bug fixed<commit_after>module Fastlane
  module Actions
    class GetVersionNumberFromGitBranchAction < Action
      def self.run(params)
        if Helper.test?
          branch = 'releases/release-1.3.5'
        else
          branch = Actions.git_branch
        end

        pattern = params[:pattern].dup
        pattern["#"] = "(.*)"

        match = Regexp.new(pattern).match(branch)
        UI.user_error!("Cannot find version number in git branch '#{branch}' by pattern '#{params[:pattern]}'") unless match
        match[1]
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Extract version number from git branch name"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :pattern,
                             env_name: "FL_VERSION_NUMBER_FROM_GIT_BRANCH_PATTERN",
                             description: "Pattern for branch name, should contain # character in place of version number",
                             default_value: 'release-#',
                             is_string: true)
        ]
      end

      def self.authors
        ["SiarheiFedartsou"]
      end

      def self.is_supported?(platform)
        [:ios, :mac].include? platform
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.15640481245576787, 'fraction_numerical': 0.0031847133757961785, 'mean_word_length': 2.0202991452991452, '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': '3875228', 'n_tokens_mistral': 746, 'n_tokens_neox': 712, 'n_words': 177}