<s> import datetime <EOL> import re <EOL> import subprocess <EOL> RELEASE = re . compile ( r'<STR_LIT>' ) <EOL> ISSUE = re . compile ( r'<STR_LIT>' ) <EOL> REVLIST = '<STR_LIT>' <EOL> TEMPLATE = """<STR_LIT>""" <EOL> revisions = subprocess . check_output ( REVLIST , shell = True , stderr = subprocess . STDOUT ) <EOL> commit_list = [ ] <EOL> for hunk in revisions . split ( '<STR_LIT>' ) [ : - <NUM_LIT:1> ] : <EOL> lines = hunk . strip ( ) . splitlines ( ) <EOL> commit = lines [ <NUM_LIT:0> ] . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> parents = lines [ <NUM_LIT:1> ] . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] . split ( '<STR_LIT:U+0020>' ) <EOL> message = '<STR_LIT:U+0020>' . join ( lines [ <NUM_LIT:2> : ] ) <EOL> if RELEASE . search ( message ) : <EOL> print ( '<STR_LIT>' ) <EOL> print ( message ) <EOL> break <EOL> if len ( parents ) > <NUM_LIT:1> : <EOL> commit_list . append ( [ commit , message ] ) <EOL> removals = [ <EOL> re . compile ( r'<STR_LIT>' , re . I ) , <EOL> re . compile ( r"<STR_LIT>" , re . I ) , <EOL> re . compile ( r'<STR_LIT>' , re . I ) <EOL> ] <EOL> changes = '<STR_LIT>' <EOL> for commit , message in commit_list : <EOL> append = [ ] <EOL> issues = set ( ) <EOL> for issue in ISSUE . findall ( message ) : <EOL> if issue not in issues : <EOL> append . append ( '<STR_LIT>' . format ( issue = issue ) ) <EOL> issues . add ( issue ) <EOL> append . append ( '<STR_LIT>' . format ( commit = commit ) ) <EOL> append = '<STR_LIT>' + '<STR_LIT:U+002CU+0020>' . join ( append ) + '<STR_LIT:)>' <EOL> original = message <EOL> for removal in removals : <EOL> message = removal . sub ( '<STR_LIT>' , message ) <EOL> message = message . strip ( ) <EOL> if not message : <EOL> message = original . strip ( ) <EOL> changes += '<STR_LIT>' + message + append + '<STR_LIT:\n>' <EOL> print ( TEMPLATE . format ( <EOL> version = '<STR_LIT>' , <EOL> date = datetime . datetime . now ( ) . strftime ( '<STR_LIT>' ) , <EOL> changes = changes <EOL> ) ) </s>
