<s> import git <EOL> import re <EOL> from djtracker import models <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from django . core . management . base import NoArgsCommand <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . contrib . comments . models import Comment <EOL> from django . contrib . sites . models import Site <EOL> from django . conf import settings <EOL> class Command ( NoArgsCommand ) : <EOL> """<STR_LIT>""" <EOL> help = "<STR_LIT>" <EOL> def start_parser ( self ) : <EOL> self . content_type = ContentType . objects . get ( model = '<STR_LIT>' ) <EOL> projects = models . Project . objects . all ( ) <EOL> for x in projects : <EOL> if x . git_repo_path : <EOL> self . parse_repo ( x ) <EOL> def parse_repo ( self , project ) : <EOL> repo = git . Repo ( project . git_repo_path ) <EOL> starting_commit = project . git_repo_commit <EOL> commits = repo . commits ( ) <EOL> for x in commits : <EOL> if starting_commit == x . id : <EOL> starting_commit = x <EOL> index = commits . index ( starting_commit ) <EOL> commits = commits [ : index ] <EOL> match_string = re . compile ( '<STR_LIT>' ) <EOL> issue_matches = [ ] <EOL> for x in commits : <EOL> for message in match_string . findall ( x . message ) : <EOL> issue_matches . append ( x ) <EOL> number_string = re . compile ( '<STR_LIT>' ) <EOL> closed_status = models . Status . objects . get ( slug = "<STR_LIT>" ) <EOL> for x in issue_matches : <EOL> for y in number_string . findall ( x . message ) : <EOL> try : <EOL> issue = models . Issue . objects . get ( id = y ) <EOL> if issue . status is closed_status : <EOL> continue <EOL> except ObjectDoesNotExist : <EOL> continue <EOL> issue . status = closed_status <EOL> issue . save ( ) <EOL> comment = Comment ( ) <EOL> comment . user_name = "<STR_LIT>" <EOL> comment . user_email = "<STR_LIT>" <EOL> comment . content_type = self . content_type <EOL> comment . object_pk = issue . id <EOL> comment . comment = x . message <EOL> comment . site = Site . objects . get ( id = settings . SITE_ID ) <EOL> comment . save ( ) <EOL> project . git_repo_commit = x . id <EOL> project . save ( ) <EOL> def handle_noargs ( self , ** options ) : <EOL> self . start_parser ( ) </s>
