#NEWLINE# @ contextlib . contextmanager #NEWLINE# def fetch( self , ref ) : #NEWLINE# #INDENT# if ( ref in self . fetched_paths ) : #NEWLINE# #INDENT# ( yield self . fetched_paths [ ref ] ) #NEWLINE# return #NEWLINE# #UNINDENT# logger = self . get_logger ( 'fetch' ) #NEWLINE# with super ( PullRequest , self ) . fetch ( self . name ) as path : #NEWLINE# #INDENT# def git( command , * args , **kwargs ) : #NEWLINE# #INDENT# command = ( 'git --git-dir="{git_dir}" --work-tree="{work_tree}" ' + command ) #NEWLINE# kwargs . update ( git_dir = os . path . join ( path , '.git' ) , work_tree = path ) #NEWLINE# cmd = command . format ( * args , ** kwargs ) #NEWLINE# logger . info ( '%s' , cmd ) #NEWLINE# with os . popen ( cmd ) as f : #NEWLINE# #INDENT# for line in f : #NEWLINE# #INDENT# logger . debug ( '[%s] %s' , cmd , line ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# git ( 'checkout {0}' , self . pull_request . base . sha ) #NEWLINE# git ( 'checkout -b asuka-pullreq-{0}' , self . number ) #NEWLINE# git ( 'pull "{0}" "{1}":asuka-pullreq-{2}' , self . app . get_clone_url ( self . repository ) , self . pull_request . head . ref , self . number ) #NEWLINE# git ( 'checkout "{0}"' , self . name ) #NEWLINE# git ( 'checkout -b asuka-mergedpullreq-{0}' , self . number ) #NEWLINE# git ( 'merge "{0}"' , ref ) #NEWLINE# git ( 'branch -D asuka-pullreq-{0}' , self . number ) #NEWLINE# ( yield path ) #NEWLINE# git ( 'checkout "{0}"' , self . name ) #NEWLINE# git ( 'branch -D asuka-mergedpullreq-{0}' , self . number )