<commit_before>import sys
import fileinput
import subprocess
import run_python as package

def release(type='minor', level='final'):
    """
    Release package with version type and level.
    Types:
    - major
    - minor
    - micro
    """
    if test() == 0:
        version(action='increase', type='minor', level='final')
        commit('release')
        tag(version())

def test(): #TODO: it doesn't work from CL run test
    """
    Test package.
    """
    return subprocess.call('nosetests', shell=True)

def version(action='print', type='minor', level='final'):
    """
    Print or increase with type and level package version.   
    Actions:
    - print
    - increase
    Types:
    - major
    - minor
    - micro
    """
    if action == 'print':
        print(package.__version__)
    elif action == 'increase':
        for line in fileinput.input(package.__name__+'/version.py', inplace=True):
            if line.strip().startswith(type.upper()):
                current = getattr(package.__version__, type.upper())     
                line = line.replace(str(current), str(current+1))
            if line.strip().startswith('RELEASELEVEL'):
                line = line.replace(package.__version__.RELEASELEVEL, level)
            sys.stdout.write(line)
        reload(package)
        
def commit(message):
    """
    Commit changes with message.
    """
    subprocess.call(['git commit -am "{message}"'.
                     format(message=message)], shell=True)
    
def tag(name):
    """
    Add tag name.
    """
    subprocess.call(['git tag {name}'.
                     format(name=name)], shell=True)   <commit_msg>updated runfile<commit_after>import sys
import fileinput
import subprocess
import run_python as package

def release(type='minor', level='final'):
    """
    Release package with version type and level.
    Types:
    - major
    - minor
    - micro
    """
    if test() == 0:
        commit()
        version(action='increase', type=type, level=level)
        commit(message='updated version')
        push(branch='develop')
        checkout(branch='master')
        merge(branch='develop')
        tag(name=version(action='return'))
        push(branch='master', tags=True)
        checkout(branch='develop')
        
def test():
    """
    Test package.
    """
    command = ['nosetests']
    return subprocess.call(command)

def version(action='print', type='minor', level='final'):
    """
    Print or increase with type and level package version.   
    Actions:
    - print
    - increase
    Types:
    - major
    - minor
    - micro
    """
    version = package.__version__
    if action == 'return':
        return version    
    elif action == 'print':
        print(version)
    elif action == 'increase':
        module = sys.modules[version.__module__]
        source = module. __file__.replace('.pyc', '.py')
        for line in fileinput.input(source, inplace=True):
            if line.strip().startswith(type.upper()):
                current = getattr(package.__version__, type.upper())     
                line = line.replace(str(current), str(current+1))
            if line.strip().startswith('RELEASELEVEL'):
                line = line.replace(version.RELEASELEVEL, level)
            sys.stdout.write(line)
        reload(module)
        reload(package)
        
def commit(message=None):
    """
    Commit changes with message.
    """
    command = ['git', 'commit', '-a']
    if message:
        command.append('-m')
        command.append(message)
    subprocess.call(command)
    
def tag(name):
    """
    Add tag name.
    """
    command = ['git', 'tag', name]
    subprocess.call(command)
    
def checkout(branch):
    """
    Checkout branch.
    """
    command = ['git', 'checkout', branch]
    subprocess.call(command)
    
def merge(branch):
    """
    Merge branch.
    """
    command = ['git', 'merge', branch]
    subprocess.call(command)
    
def push(branch, tags=False):
    """
    Push branch to origin.
    """
    command = ['git', 'push', 'origin', branch]
    if tags:
        command.append('--tags')
    subprocess.call(command)
{'fraction_non_alphanumeric': 0.14037626628075253, 'fraction_numerical': 0.000964785335262904, 'mean_word_length': 2.2705047318611986, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2515202', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1171, 'n_words': 285}