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

#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Process all of the release requests in changed files in the commit.
"""

import argparse
import os.path
import re
import sys
import subprocess

import yaml


# TODO(dhellmann): Instead of using a fixed list, look for the series
# name -eol tag to determine that a series is closed.
CLOSED_SERIES = set([
    'austin',
    'bexar',
    'cactus',
    'diablo',
    'essex',
    'folsom',
    'grizzly',
    'havana',
    'icehouse',
    'juno',
    'kilo',
    'liberty',
    'mitaka',
])

PRE_RELEASE_RE = re.compile('''
    \.(\d+(?:[ab]|rc)+\d*)$
''', flags=re.VERBOSE | re.UNICODE)

BINDIR = os.path.dirname(sys.argv[0])
RELEASE_SCRIPT = os.path.join(BINDIR, 'release.sh')
BRANCH_SCRIPT = os.path.join(BINDIR, 'make_branch.sh')


def find_modified_deliverable_files(reporoot):
    "Return a list of files modified by the most recent commit."
    results = subprocess.check_output(
        ['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^'],
        cwd=reporoot,
    ).decode('utf-8')
    filenames = [
        l.strip()
        for l in results.splitlines()
        if l.startswith('deliverables/')
    ]
    return filenames


def tag_release(repo, series_name, version, diff_start, hash,
                include_pypi_link, first_full_release, meta_data):
    print('Tagging {} in {}'.format(version, repo))
    try:
        subprocess.check_call(
            [RELEASE_SCRIPT, repo, series_name, version,
             diff_start, hash, include_pypi_link,
             first_full_release, meta_data]
        )
    except subprocess.CalledProcessError:
        # The error output from the script will be printed to
        # stderr, so we don't need to do anything else here.
        return 1
    return 0


def make_branch(repo, name, ref):<commit_msg>ignore the series_status.yaml when processing release requests<commit_after>#!/usr/bin/env python3

#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Process all of the release requests in changed files in the commit.
"""

import argparse
import os.path
import re
import sys
import subprocess

import yaml


# TODO(dhellmann): Instead of using a fixed list, look for the series
# name -eol tag to determine that a series is closed.
CLOSED_SERIES = set([
    'austin',
    'bexar',
    'cactus',
    'diablo',
    'essex',
    'folsom',
    'grizzly',
    'havana',
    'icehouse',
    'juno',
    'kilo',
    'liberty',
    'mitaka',
])

PRE_RELEASE_RE = re.compile('''
    \.(\d+(?:[ab]|rc)+\d*)$
''', flags=re.VERBOSE | re.UNICODE)

BINDIR = os.path.dirname(sys.argv[0])
RELEASE_SCRIPT = os.path.join(BINDIR, 'release.sh')
BRANCH_SCRIPT = os.path.join(BINDIR, 'make_branch.sh')


def find_modified_deliverable_files(reporoot):
    "Return a list of files modified by the most recent commit."
    results = subprocess.check_output(
        ['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^'],
        cwd=reporoot,
    ).decode('utf-8')
    filenames = [
        l.strip()
        for l in results.splitlines()
        if (l.startswith('deliverables/') and
            not l.endswith('series_status.yaml'))
    ]
    return filenames


def tag_release(repo, series_name, version, diff_start, hash,
                include_pypi_link, first_full_release, meta_data):
    print('Tagging {} in {}'.format(version, repo))
    try:
        subprocess.check_call(
            [RELEASE_SCRIPT, repo, series_name, version,
             diff_start, hash, include_pypi_link,
             first_full_release, meta_data]
        )
    except subprocess.CalledProcessError:
        # The error output from the script will be printed to
        # stderr, so we don't need to do anything else here.
        return 1
    return 0


def make_branch(repo, name, ref):
{'fraction_non_alphanumeric': 0.11168243521184698, 'fraction_numerical': 0.003702180172768408, 'mean_word_length': 2.9958915365653245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3959937', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1530, 'n_words': 486}