<commit_before>module Deployinator
  module Stacks
    module Smart5
      def smart5_git_repo_url
        "git@github.com:xfactoradvertising/smart.git"
      end

      def smart5_user
        'www-data'
      end

      def smart5_stage_ip
        '172.16.58.3'
      end

      def smart5_prod_ip
        '172.16.58.3'
      end

      def checkout_root
        "/tmp"
      end

      def site_root
        '/var/www/sites'
      end

      def site_path
        "#{site_root}/#{stack}"
      end

      def smart5_git_checkout_path
        "#{checkout_root}/#{stack}"
      end

      def smart5_stage_version
        %x{ssh #{smart5_user}@#{smart5_stage_ip} 'cat #{site_path}/version.txt'}
      end

      def smart5_stage_build
        Version.get_build(smart5_stage_version)
      end

      def smart5_prod_version
        %x{ssh #{smart5_user}@#{smart5_prod_ip} 'cat #{site_path}/version.txt'}
      end

      def smart5_prod_build
        Version.get_build(smart5_prod_version)
      end

      def smart5_head_build
        #%x{git ls-remote #{smart5_git_repo_url} HEAD | cut -c1-7}.chomp

        # NOTE explicitly getting smart5 branch HEAD revision here
        %x{git ls-remote #{smart5_git_repo_url} smart5 HEAD | tail -1 | cut -c1-7}.chomp
      end

      def smart5_stage(options={})
        old_build = smart5_stage_build

        git_cmd = old_build ? :git_freshen_clone_branch : :github_clone_branch
        send(git_cmd, stack, 'sh -c')

        git_bump_version stack, ''

        build = smart5_head_build

        begin
          # take application offline (maintenance mode)
          # return true so command is non-fatal (artisan doesn't exist the first time)
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/bin/php artisan down --env=stage || true"}

          # sync new app contents
          run_cmd %Q{rsync -ave ssh --delete --force --exclude='storage/*/*/**' --exclude='vendor/' --exclude='.git/' --exclude='.gitignore' --exclude='.env' --filter "protect .env" --filter "protect down" --filter "protect vendor/" --filter "protect storage/*/**" #{smart5_git_checkout_path}/ #{smart5_user}@#{smart5_stage_ip}:#{site_path}}

          # install dependencies
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/local/bin/composer install --no-dev"}

          # run db migrations
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/bin/php artisan migrate --seed --env=stage"}<commit_msg>fix(checkout): add branch to git cmd<commit_after>module Deployinator
  module Stacks
    module Smart5
      def smart5_git_repo_url
        "git@github.com:xfactoradvertising/smart.git"
      end

      def smart5_user
        'www-data'
      end

      def smart5_stage_ip
        '172.16.58.3'
      end

      def smart5_prod_ip
        '172.16.58.3'
      end

      def checkout_root
        "/tmp"
      end

      def site_root
        '/var/www/sites'
      end

      def site_path
        "#{site_root}/#{stack}"
      end

      def smart5_git_checkout_path
        "#{checkout_root}/#{stack}"
      end

      def smart5_stage_version
        %x{ssh #{smart5_user}@#{smart5_stage_ip} 'cat #{site_path}/version.txt'}
      end

      def smart5_stage_build
        Version.get_build(smart5_stage_version)
      end

      def smart5_prod_version
        %x{ssh #{smart5_user}@#{smart5_prod_ip} 'cat #{site_path}/version.txt'}
      end

      def smart5_prod_build
        Version.get_build(smart5_prod_version)
      end

      def smart5_head_build
        #%x{git ls-remote #{smart5_git_repo_url} HEAD | cut -c1-7}.chomp

        # NOTE explicitly getting smart5 branch HEAD revision here
        %x{git ls-remote #{smart5_git_repo_url} smart5 HEAD | tail -1 | cut -c1-7}.chomp
      end

      def smart5_stage(options={})
        old_build = smart5_stage_build

        git_cmd = old_build ? :git_freshen_clone_branch : :github_clone_branch
        send(git_cmd, stack, 'smart5', 'sh -c')

        git_bump_version stack, ''

        build = smart5_head_build

        begin
          # take application offline (maintenance mode)
          # return true so command is non-fatal (artisan doesn't exist the first time)
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/bin/php artisan down --env=stage || true"}

          # sync new app contents
          run_cmd %Q{rsync -ave ssh --delete --force --exclude='storage/*/*/**' --exclude='vendor/' --exclude='.git/' --exclude='.gitignore' --exclude='.env' --filter "protect .env" --filter "protect down" --filter "protect vendor/" --filter "protect storage/*/**" #{smart5_git_checkout_path}/ #{smart5_user}@#{smart5_stage_ip}:#{site_path}}

          # install dependencies
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/local/bin/composer install --no-dev"}

          # run db migrations
          run_cmd %Q{ssh #{smart5_user}@#{smart5_stage_ip} "cd #{site_path} && /usr/bin/php artisan migrate --seed --env=stage"}
{'fraction_non_alphanumeric': 0.12128371726717858, 'fraction_numerical': 0.02146091750344556, 'mean_word_length': 2.4394041976980367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 6, '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': '607739', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1673, 'n_words': 369}