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

import argparse
import errno
import hashlib
import os
import shutil
import subprocess
import sys
import tempfile

from io import StringIO
from lib.config import PLATFORM, get_target_arch,  get_env_var, s3_config, \
                       get_zip_name
from lib.util import electron_gyp, execute, get_electron_version, \
                     parse_version, scoped_cwd, s3put
from lib.github import GitHub


ELECTRON_REPO = 'electron/electron'
ELECTRON_VERSION = get_electron_version()

PROJECT_NAME = electron_gyp()['project_name%']
PRODUCT_NAME = electron_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 = get_zip_name(PROJECT_NAME, ELECTRON_VERSION)
SYMBOLS_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'symbols')
DSYM_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'dsym')
PDB_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'pdb')


def main():
  args = parse_args()

  if not dist_newer_than_head():
    run_python_script('create-dist.py')

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

  github = GitHub(auth_token())
  releases = github.repos(ELECTRON_REPO).releases.get()
  tag_exists = False
  for r in releases:
    if not r['draft'] and r['tag_name'] == args.version:
      release = r
      tag_exists = True
      break

  if not args.upload_to_s3:
    assert tag_exists == args.overwrite, \
          'You have to pass --overwrite to overwrite a published release'
    if not args.overwrite:
      release = create_or_get_release_draft(github, releases, args.version,
                                            tag_exists)

  # Upload Electron with GitHub Releases API.
  upload_electron(github, release, os.path.join(DIST_DIR, DIST_NAME),
                  args.upload_to_s3)
  upload_electron(github, release, os.path.join(DIST_DIR, SYMBOLS_NAME),
                  args.upload_to_s3)
  if PLATFORM == 'darwin':
    upload_electron(github, release, os.path.join(DIST_DIR,
                    'electron-api.json'), args.upload_to_s3)
    upload_electron(github, release, os.path.join(DIST_DIR, 'electron.d.ts'),
                    args.upload_to_s3)
    upload_electron(github, release, os.path.join(DIST_DIR, DSYM_NAME),
                    args.upload_to_s3)
  elif PLATFORM == 'win32':
    upload_electron(github, release, os.path.join(DIST_DIR, PDB_NAME),
                    args.upload_to_s3)

  # Upload free version of ffmpeg.
  ffmpeg = get_zip_name('ffmpeg', ELECTRON_VERSION)
  upload_electron(github, release, os.path.join(DIST_DIR, ffmpeg),
                  args.upload_to_s3)

  # Upload chromedriver and mksnapshot for minor version update.
  if parse_version(args.version)[2] == '0':
    chromedriver = get_zip_name('chromedriver', ELECTRON_VERSION)
    upload_electron(github, release, os.path.join(DIST_DIR, chromedriver),
                    args.upload_to_s3)
    mksnapshot = get_zip_name('mksnapshot', ELECTRON_VERSION)
    upload_electron(github, release, os.path.join(DIST_DIR, mksnapshot),
                    args.upload_to_s3)

  # TODO: make s3 compatible

  if PLATFORM == 'win32' and not tag_exists:
    # Upload PDBs to Windows symbol server.
    run_python_script('upload-windows-pdb.py')

    # Upload node headers.
    run_python_script('create-node-headers.py', '-v', args.version)
    run_python_script('upload-node-headers.py', '-v', args.version)


def parse_args():
  parser = argparse.ArgumentParser(description='upload distribution file')
  parser.add_argument('-v', '--version', help='Specify the version',
                      default=ELECTRON_VERSION)
  parser.add_argument('-o', '--overwrite',
                      help='Overwrite a published release',
                      action='store_true')
  parser.add_argument('-p', '--publish-release',
                      help='Publish the release',
                      action='store_true')
  parser.add_argument('-s', '--upload_to_s3',
                      help='Upload assets to s3 bucket',
                      dest='upload_to_s3',<commit_msg>skip headers and pdbs for fake release builds<commit_after>#!/usr/bin/env python

import argparse
import errno
import hashlib
import os
import shutil
import subprocess
import sys
import tempfile

from io import StringIO
from lib.config import PLATFORM, get_target_arch,  get_env_var, s3_config, \
                       get_zip_name
from lib.util import electron_gyp, execute, get_electron_version, \
                     parse_version, scoped_cwd, s3put
from lib.github import GitHub


ELECTRON_REPO = 'electron/electron'
ELECTRON_VERSION = get_electron_version()

PROJECT_NAME = electron_gyp()['project_name%']
PRODUCT_NAME = electron_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 = get_zip_name(PROJECT_NAME, ELECTRON_VERSION)
SYMBOLS_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'symbols')
DSYM_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'dsym')
PDB_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'pdb')


def main():
  args = parse_args()

  if not dist_newer_than_head():
    run_python_script('create-dist.py')

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

  github = GitHub(auth_token())
  releases = github.repos(ELECTRON_REPO).releases.get()
  tag_exists = False
  for r in releases:
    if not r['draft'] and r['tag_name'] == args.version:
      release = r
      tag_exists = True
      break

  if not args.upload_to_s3:
    assert tag_exists == args.overwrite, \
          'You have to pass --overwrite to overwrite a published release'
    if not args.overwrite:
      release = create_or_get_release_draft(github, releases, args.version,
                                            tag_exists)

  # Upload Electron with GitHub Releases API.
  upload_electron(github, release, os.path.join(DIST_DIR, DIST_NAME),
                  args.upload_to_s3)
  upload_electron(github, release, os.path.join(DIST_DIR, SYMBOLS_NAME),
                  args.upload_to_s3)
  if PLATFORM == 'darwin':
    upload_electron(github, release, os.path.join(DIST_DIR,
                    'electron-api.json'), args.upload_to_s3)
    upload_electron(github, release, os.path.join(DIST_DIR, 'electron.d.ts'),
                    args.upload_to_s3)
    upload_electron(github, release, os.path.join(DIST_DIR, DSYM_NAME),
                    args.upload_to_s3)
  elif PLATFORM == 'win32':
    upload_electron(github, release, os.path.join(DIST_DIR, PDB_NAME),
                    args.upload_to_s3)

  # Upload free version of ffmpeg.
  ffmpeg = get_zip_name('ffmpeg', ELECTRON_VERSION)
  upload_electron(github, release, os.path.join(DIST_DIR, ffmpeg),
                  args.upload_to_s3)

  # Upload chromedriver and mksnapshot for minor version update.
  if parse_version(args.version)[2] == '0':
    chromedriver = get_zip_name('chromedriver', ELECTRON_VERSION)
    upload_electron(github, release, os.path.join(DIST_DIR, chromedriver),
                    args.upload_to_s3)
    mksnapshot = get_zip_name('mksnapshot', ELECTRON_VERSION)
    upload_electron(github, release, os.path.join(DIST_DIR, mksnapshot),
                    args.upload_to_s3)

  if PLATFORM == 'win32' and not tag_exists and not args.upload_to_s3:
    # Upload PDBs to Windows symbol server.
    run_python_script('upload-windows-pdb.py')

    # Upload node headers.
    run_python_script('create-node-headers.py', '-v', args.version)
    run_python_script('upload-node-headers.py', '-v', args.version)


def parse_args():
  parser = argparse.ArgumentParser(description='upload distribution file')
  parser.add_argument('-v', '--version', help='Specify the version',
                      default=ELECTRON_VERSION)
  parser.add_argument('-o', '--overwrite',
                      help='Overwrite a published release',
                      action='store_true')
  parser.add_argument('-p', '--publish-release',
                      help='Publish the release',
                      action='store_true')
  parser.add_argument('-s', '--upload_to_s3',
                      help='Upload assets to s3 bucket',
                      dest='upload_to_s3',
{'fraction_non_alphanumeric': 0.10800090661831369, 'fraction_numerical': 0.005666364460562103, 'mean_word_length': 3.1943916349809887, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7102434', 'n_tokens_mistral': 2987, 'n_tokens_neox': 2805, 'n_words': 583}