<s> import json <EOL> import urllib2 <EOL> from fabric . api import abort , env , local , task <EOL> from fabric . contrib . console import confirm <EOL> from . utils import git , ui <EOL> @ task ( default = True ) <EOL> def merge ( number ) : <EOL> '''<STR_LIT>''' <EOL> author , branch = patch ( number ) <EOL> upstream = env . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> print ui . info ( '<STR_LIT>' ) <EOL> git . rebase_remote ( upstream ) <EOL> commits_ahead = git . commits_ahead ( upstream ) <EOL> local ( '<STR_LIT>' % commits_ahead ) <EOL> if not confirm ( ui . warning ( '<STR_LIT>' ) ) : <EOL> abort ( '<STR_LIT>' ) <EOL> local ( '<STR_LIT>' % branch ) <EOL> git . rebase_remote ( upstream ) <EOL> local ( '<STR_LIT>' % upstream ) <EOL> print ui . success ( '<STR_LIT>' ) <EOL> local ( '<STR_LIT>' % branch ) <EOL> @ task <EOL> def patch ( number ) : <EOL> '''<STR_LIT>''' <EOL> url = '<STR_LIT>' % number <EOL> pr = json . loads ( urllib2 . urlopen ( url ) . read ( ) ) <EOL> author = pr [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] [ '<STR_LIT>' ] <EOL> repo = pr [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> branch = pr [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> print ui . info ( '<STR_LIT>' % ( branch , author ) ) <EOL> local ( '<STR_LIT>' % ( repo , branch , branch ) ) <EOL> local ( '<STR_LIT>' % branch ) <EOL> return ( author , branch ) </s>
