<commit_before>#!/usr/bin/env python

import argparse
import errno
import os
import subprocess
import sys
import tempfile

from lib.config import PLATFORM, get_target_arch
from lib.util import atom_gyp, execute, get_atom_shell_version, parse_version, \
                     get_chromedriver_version, scoped_cwd
from lib.github import GitHub


ATOM_SHELL_REPO = 'atom/electron'
ATOM_SHELL_VERSION = get_atom_shell_version()

PROJECT_NAME = atom_gyp()['project_name%']
PRODUCT_NAME = atom_gyp()['product_name%']

SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
DIST_NAME = '{0}-{1}-{2}-{3}.zip'.format(PROJECT_NAME,
                                         ATOM_SHELL_VERSION,
                                         PLATFORM,
                                         get_target_arch())
SYMBOLS_NAME = '{0}-{1}-{2}-{3}-symbols.zip'.format(PROJECT_NAME,
                                                    ATOM_SHELL_VERSION,
                                                    PLATFORM,
                                                    get_target_arch())
MKSNAPSHOT_NAME = 'mksnapshot-{0}-{1}-{2}.zip'.format(ATOM_SHELL_VERSION,
                                                      PLATFORM,
                                                      get_target_arch())


def main():
  args = parse_args()

  if not dist_newer_than_head():
    create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
    execute([sys.executable, create_dist])

  build_version = get_atom_shell_build_version()
  if not ATOM_SHELL_VERSION.startswith(build_version):
    error = 'Tag name ({0}) should match build version ({1})\n'.format(
        ATOM_SHELL_VERSION, build_version)
    sys.stderr.write(error)
    sys.stderr.flush()
    return 1

  github = GitHub(auth_token())
  release_id = create_or_get_release_draft(github, args.version)

  if args.publish_release:
    # Upload the SHASUMS.txt.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
             '-v', ATOM_SHELL_VERSION])

    # Upload the index.json.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-index-json.py')])

    # Press the publish button.
    publish_release(github, release_id)

    # Do not upload other files when passed "-p".
    return

  # Upload atom-shell with GitHub Releases API.
  upload_atom_shell(github, release_id, os.path.join(DIST_DIR, DIST_NAME))
  upload_atom_shell(github, release_id, os.path.join(DIST_DIR, SYMBOLS_NAME))

  # Upload chromedriver and mksnapshot for minor version update.
  if parse_version(args.version)[2] == '0':
    upload_atom_shell(github, release_id,
                      os.path.join(DIST_DIR, MKSNAPSHOT_NAME))

    if get_target_arch() != 'arm':
      chromedriver = 'chromedriver-{0}-{1}-{2}.zip'.format(
          get_chromedriver_version(), PLATFORM, get_target_arch())
      upload_atom_shell(github, release_id,
                        os.path.join(DIST_DIR, chromedriver))

  if PLATFORM == 'win32':
    # Upload node headers.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-node-headers.py'),
             '-v', ATOM_SHELL_VERSION])


def parse_args():
  parser = argparse.ArgumentParser(description='upload distribution file')
  parser.add_argument('-v', '--version', help='Specify the version',
                      default=ATOM_SHELL_VERSION)
  parser.add_argument('-p', '--publish-release',
                      help='Publish the release',
                      action='store_true')
  return parser.parse_args()
<commit_msg>Don't upload arm version of mksnapshot too<commit_after>#!/usr/bin/env python

import argparse
import errno
import os
import subprocess
import sys
import tempfile

from lib.config import PLATFORM, get_target_arch
from lib.util import atom_gyp, execute, get_atom_shell_version, parse_version, \
                     get_chromedriver_version, scoped_cwd
from lib.github import GitHub


ATOM_SHELL_REPO = 'atom/electron'
ATOM_SHELL_VERSION = get_atom_shell_version()

PROJECT_NAME = atom_gyp()['project_name%']
PRODUCT_NAME = atom_gyp()['product_name%']

SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
DIST_NAME = '{0}-{1}-{2}-{3}.zip'.format(PROJECT_NAME,
                                         ATOM_SHELL_VERSION,
                                         PLATFORM,
                                         get_target_arch())
SYMBOLS_NAME = '{0}-{1}-{2}-{3}-symbols.zip'.format(PROJECT_NAME,
                                                    ATOM_SHELL_VERSION,
                                                    PLATFORM,
                                                    get_target_arch())
MKSNAPSHOT_NAME = 'mksnapshot-{0}-{1}-{2}.zip'.format(ATOM_SHELL_VERSION,
                                                      PLATFORM,
                                                      get_target_arch())


def main():
  args = parse_args()

  if not dist_newer_than_head():
    create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
    execute([sys.executable, create_dist])

  build_version = get_atom_shell_build_version()
  if not ATOM_SHELL_VERSION.startswith(build_version):
    error = 'Tag name ({0}) should match build version ({1})\n'.format(
        ATOM_SHELL_VERSION, build_version)
    sys.stderr.write(error)
    sys.stderr.flush()
    return 1

  github = GitHub(auth_token())
  release_id = create_or_get_release_draft(github, args.version)

  if args.publish_release:
    # Upload the SHASUMS.txt.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
             '-v', ATOM_SHELL_VERSION])

    # Upload the index.json.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-index-json.py')])

    # Press the publish button.
    publish_release(github, release_id)

    # Do not upload other files when passed "-p".
    return

  # Upload atom-shell with GitHub Releases API.
  upload_atom_shell(github, release_id, os.path.join(DIST_DIR, DIST_NAME))
  upload_atom_shell(github, release_id, os.path.join(DIST_DIR, SYMBOLS_NAME))

  # Upload chromedriver and mksnapshot for minor version update.
  if get_target_arch() != 'arm' and parse_version(args.version)[2] == '0':
    chromedriver = 'chromedriver-{0}-{1}-{2}.zip'.format(
        get_chromedriver_version(), PLATFORM, get_target_arch())
    upload_atom_shell(github, release_id,
                      os.path.join(DIST_DIR, chromedriver))
    upload_atom_shell(github, release_id,
                      os.path.join(DIST_DIR, MKSNAPSHOT_NAME))

  if PLATFORM == 'win32':
    # Upload node headers.
    execute([sys.executable,
             os.path.join(SOURCE_ROOT, 'script', 'upload-node-headers.py'),
             '-v', ATOM_SHELL_VERSION])


def parse_args():
  parser = argparse.ArgumentParser(description='upload distribution file')
  parser.add_argument('-v', '--version', help='Specify the version',
                      default=ATOM_SHELL_VERSION)
  parser.add_argument('-p', '--publish-release',
                      help='Publish the release',
                      action='store_true')
  return parser.parse_args()

{'fraction_non_alphanumeric': 0.11580931861028818, 'fraction_numerical': 0.005655803932130353, 'mean_word_length': 2.4448051948051948, 'pattern_counts': {'":': 0, '<': 3, '<?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': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '868064', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2258, 'n_words': 420}