<commit_before>import subprocess, sys, os
from pprint import pformat
from optparse import OptionParser

def run_command(command, cwd='.'):
    #print('Running command: ')
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, cwd=cwd)
    out, err = process.communicate()
    out = out.strip('\n')
    #print(pformat(out.split('\n')))
    if process.returncode:
        print('failed: %d' % process.returncode)
        return None
    return out.split('\n')
  
def main(options, args):
    output = run_command(['git', 'diff', '--no-color', '--', 'fml'])
    if output is None:
        print('Failed to grab submodule commits')
        sys.exit(1)
    
    start = None
    end = None
    for line in output:
        if not 'Subproject commit' in line:
            continue
        if line[0:18] == '-Subproject commit':
            start = line[19:]
        elif line[0:18] == '+Subproject commit':
            end = line[19:]
    
    if start == None or end == None:
        print('Could not extract start and end range')
        sys.exit(1)
    
    output = run_command(['git', 'log', '--reverse', '--pretty=oneline', '%s...%s' % (start, end)], './fml')
    print('Updated FML:')
    for line in output:<commit_msg>Support dirty submodules in changelog script.<commit_after>import subprocess, sys, os
from pprint import pformat
from optparse import OptionParser

def run_command(command, cwd='.'):
    #print('Running command: ')
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, cwd=cwd)
    out, err = process.communicate()
    out = out.strip('\n')
    #print(pformat(out.split('\n')))
    if process.returncode:
        print('failed: %d' % process.returncode)
        return None
    return out.split('\n')
  
def main(options, args):
    output = run_command(['git', 'diff', '--no-color', '--', 'fml'])
    if output is None:
        print('Failed to grab submodule commits')
        sys.exit(1)
    
    start = None
    end = None
    for line in output:
        if not 'Subproject commit' in line:
            continue
        if line[0:18] == '-Subproject commit':
            start = line[19:]
        elif line[0:18] == '+Subproject commit':
            end = line[19:]
            if end.endswith('-dirty'):
                end = end[0:len(end)-6]
    
    if start == None or end == None:
        print('Could not extract start and end range')
        sys.exit(1)
    
    print('Start: %s' % start)
    print('End: %s' % end)
    
    output = run_command(['git', 'log', '--reverse', '--pretty=oneline', '%s...%s' % (start, end)], './fml')
    print('Updated FML:')
    for line in output:
{'fraction_non_alphanumeric': 0.15515988372093023, 'fraction_numerical': 0.010174418604651164, 'mean_word_length': 2.593994778067885, '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': '4294574', 'n_tokens_mistral': 898, 'n_tokens_neox': 879, 'n_words': 240}