<commit_before>require 'spaceship'

module Sigh
  class Runner
    attr_accessor :spaceship

    # Uses the spaceship to create or download a provisioning profile
    # returns the path the newly created provisioning profile (in /tmp usually)
    def run
      Helper.log.info "Starting login"
      Spaceship.login(Sigh.config[:username], nil)
      Spaceship.select_team
      Helper.log.info "Successfully logged in"

      profiles = [] if Sigh.config[:skip_fetch_profiles]
      profiles ||= fetch_profiles # download the profile if it's there

      if profiles.count > 0
        Helper.log.info "Found #{profiles.count} matching profile(s)".yellow
        profile = profiles.first

        if Sigh.config[:force]
          if profile_type == Spaceship.provisioning_profile::AppStore or profile_type == Spaceship.provisioning_profile::InHouse
            Helper.log.info "Updating the provisioning profile".yellow
          else
            Helper.log.info "Updating the profile to include all devices".yellow
            profile.devices = Spaceship.device.all
          end

          profile = profile.update! # assign it, as it's a new profile
        end
      else
        Helper.log.info "No existing profiles, creating a new one for you".yellow
        profile = create_profile!
      end

      raise "Something went wrong fetching the latest profile".red unless profile

      return download_profile(profile)
    end

    # The kind of provisioning profile we're interested in
    def profile_type
      return @profile_type if @profile_type

      @profile_type = Spaceship.provisioning_profile.app_store
      @profile_type = Spaceship.provisioning_profile.ad_hoc if Sigh.config[:adhoc]
      @profile_type = Spaceship.provisioning_profile.development if Sigh.config[:development]
      @profile_type = Spaceship.provisioning_profile.in_house if Spaceship.client.in_house?

      @profile_type
    end

    # Fetches a profile matching the user's search requirements
    def fetch_profiles
      Helper.log.info "Fetching profiles..."
      results = profile_type.find_by_bundle_id(Sigh.config[:app_identifier]).find_all { |a| a.valid? }

      return results if Sigh.config[:skip_certificate_verification]


      return results.find_all do |a|
        # Also make sure we have the certificate installed on the local machine
        installed = false
        a.certificates.each do |cert|<commit_msg>enable developement and adhoc options in case of Enterprise account<commit_after>require 'spaceship'

module Sigh
  class Runner
    attr_accessor :spaceship

    # Uses the spaceship to create or download a provisioning profile
    # returns the path the newly created provisioning profile (in /tmp usually)
    def run
      Helper.log.info "Starting login"
      Spaceship.login(Sigh.config[:username], nil)
      Spaceship.select_team
      Helper.log.info "Successfully logged in"

      profiles = [] if Sigh.config[:skip_fetch_profiles]
      profiles ||= fetch_profiles # download the profile if it's there

      if profiles.count > 0
        Helper.log.info "Found #{profiles.count} matching profile(s)".yellow
        profile = profiles.first

        if Sigh.config[:force]
          if profile_type == Spaceship.provisioning_profile::AppStore or profile_type == Spaceship.provisioning_profile::InHouse
            Helper.log.info "Updating the provisioning profile".yellow
          else
            Helper.log.info "Updating the profile to include all devices".yellow
            profile.devices = Spaceship.device.all
          end

          profile = profile.update! # assign it, as it's a new profile
        end
      else
        Helper.log.info "No existing profiles, creating a new one for you".yellow
        profile = create_profile!
      end

      raise "Something went wrong fetching the latest profile".red unless profile

      return download_profile(profile)
    end

    # The kind of provisioning profile we're interested in
    def profile_type
      return @profile_type if @profile_type

      @profile_type = Spaceship.provisioning_profile.app_store
      @profile_type = Spaceship.provisioning_profile.in_house if Spaceship.client.in_house?
      @profile_type = Spaceship.provisioning_profile.ad_hoc if Sigh.config[:adhoc]
      @profile_type = Spaceship.provisioning_profile.development if Sigh.config[:development]

      @profile_type
    end

    # Fetches a profile matching the user's search requirements
    def fetch_profiles
      Helper.log.info "Fetching profiles..."
      results = profile_type.find_by_bundle_id(Sigh.config[:app_identifier]).find_all { |a| a.valid? }

      return results if Sigh.config[:skip_certificate_verification]


      return results.find_all do |a|
        # Also make sure we have the certificate installed on the local machine
        installed = false
        a.certificates.each do |cert|
{'fraction_non_alphanumeric': 0.06991005723630417, 'fraction_numerical': 0.0004088307440719542, 'mean_word_length': 2.9910277324632952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6173492', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1320, 'n_words': 400}