def check_git_remote_exists(url, version, tags_valid=False):
 cmd = ('git ls-remote %s refs/heads/*' % url).split()
 try:
  output = subprocess.check_output(cmd)
 except:
  return False
 if (not version):
  return True
 if (('refs/heads/%s' % version) in output):
  return True
 if (not tags_valid):
  return False
 cmd = ('git ls-remote %s refs/tags/*' % url).split()
 try:
  output = subprocess.check_output(cmd)
 except:
  return False
 if (('refs/tags/%s' % version) in output):
  return True
 return False

def check_git_remote_exists ( url , version , tags_valid = False ) : cmd = ( 'git ls-remote %s refs/heads/*' % url ) . split ( ) try : output = subprocess . check_output ( cmd ) except : return False if ( not version ) : return True if ( ( 'refs/heads/%s' % version ) in output ) : return True if ( not tags_valid ) : return False cmd = ( 'git ls-remote %s refs/tags/*' % url ) . split ( ) try : output = subprocess . check_output ( cmd ) except : return False if ( ( 'refs/tags/%s' % version ) in output ) : return True return False
check if the remote exists and has the branch version .