#NEWLINE# def get_remote_rev( proj_dir , remote_branch ) : #NEWLINE# #INDENT# 'get the head rev of a remote branch\n\n    :param proj_dir:        a git repo dir\n    :param remote_branch:   remote branch (e.g. origin/master)\n    :returns:               the revision string of the remote branch head or None\n    ' #NEWLINE# tokens = remote_branch . split ( '/' ) #NEWLINE# try : #NEWLINE# #INDENT# output = subprocess . check_output ( 'git ls-remote {} {}' . format ( tokens [ 0 ] , tokens [ 1 ] ) , cwd = proj_dir , shell = True ) #NEWLINE# if ( output != '' ) : #NEWLINE# #INDENT# return output . split ( ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# except subprocess . CalledProcessError : #NEWLINE# #INDENT# log . error ( "failed to call 'git ls-remote'" ) #NEWLINE# return None