Retrieve branch_info from Satellite Server
175357
def get_branch_info(self):
        
        branch_info = None
        if os.path.exists(constants.cached_branch_info):
            # use cached branch info file if less than 10 minutes old
            #  (failsafe, should be deleted at end of client run normally)
            logger.debug(u'Reading branch info from cached file.')
            ctime = datetime.utcfromtimestamp(
                os.path.getctime(constants.cached_branch_info))
            if datetime.utcnow() < (ctime + timedelta(minutes=5)):
                with io.open(constants.cached_branch_info, encoding='utf8', mode='r') as f:
                    branch_info = json.load(f)
                return branch_info
            else:
                logger.debug(u'Cached branch info is older than 5 minutes.')

        logger.debug(u'Obtaining branch information from %s',
                     self.branch_info_url)
        net_logger.info(u'GET %s', self.branch_info_url)
        response = self.session.get(self.branch_info_url,
                                    timeout=self.config.http_timeout)
        logger.debug(u'GET branch_info status: %s', response.status_code)
        if response.status_code != 200:
            logger.debug("There was an error obtaining branch information.")
            logger.debug(u'Bad status from server: %s', response.status_code)
            logger.debug("Assuming default branch information %s" % self.branch_info)
            return False

        branch_info = response.json()
        logger.debug(u'Branch information: %s', json.dumps(branch_info))

        # Determine if we are connected to Satellite 5
        if ((branch_info[u'remote_branch'] is not -1 and
             branch_info[u'remote_leaf'] is -1)):
            self.get_satellite5_info(branch_info)

        logger.debug(u'Saving branch info to file.')
        with io.open(constants.cached_branch_info, encoding='utf8', mode='w') as f:
            # json.dump is broke in py2 so use dumps
            bi_str = json.dumps(branch_info, ensure_ascii=False)
            f.write(bi_str)
        self.branch_info = branch_info
        return branch_info
731219
def member_info(self, member_id):
        """"""
        server_id = self._servers.host_to_server_id(
            self.member_id_to_host(member_id))
        server_info = self._servers.info(server_id)
        result = {'_id': member_id, 'server_id': server_id,
                  'mongodb_uri': server_info['mongodb_uri'],
                  'procInfo': server_info['procInfo'],
                  'statuses': server_info['statuses']}
        if self.login:
            result['mongodb_auth_uri'] = self.mongodb_auth_uri(
                self._servers.hostname(server_id))
        result['rsInfo'] = {}
        if server_info['procInfo']['alive']:
            # Can't call serverStatus on arbiter when running with auth enabled.
            # (SERVER-5479)
            if self.login or self.auth_key:
                arbiter_ids = [member['_id'] for member in self.arbiters()]
                if member_id in arbiter_ids:
                    result['rsInfo'] = {
                        'arbiterOnly': True, 'secondary': False, 'primary': False}
                    return result
            repl = self.run_command('serverStatus', arg=None, is_eval=False, member_id=member_id)['repl']
            logger.debug("member {member_id} repl info: {repl}".format(**locals()))
            for key in ('votes', 'tags', 'arbiterOnly', 'buildIndexes', 'hidden', 'priority', 'slaveDelay', 'votes', 'secondary'):
                if key in repl:
                    result['rsInfo'][key] = repl[key]
            result['rsInfo']['primary'] = repl.get('ismaster', False)

        return result
885003
def parse_show_server_lines(server, lines)
      s = Server.new(server)
      lines.each do |l|
        key, value = l.gsub("\t","").split(": ")
        case key.chomp
        when "active"
          s.active = value.to_bool
        when "ssh_command"
          s.ssh_cmd = value
        when "conninfo"
          s.conn_info = value
        when "backup_directory"
          s.backup_dir = value
        when "basebackups_directory"
          s.base_backups_dir = value
        when "wals_directory"
          s.wals_dir = value
        when "server_txt_version"
          s.pg_version = value
        end
      end
      return s
    end
527662
def get_remote_revision(url, branch):
    
    proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])

    try:
        while True:
            raw_line = proc.stdout.pop()
            line = raw_line.strip().decode('utf8')
            if not line:
                continue
            return line.split("\t")[0]
    finally:
        try:
            proc.join()
        except Exception:
            pass
944048
def get_branch(self, branch):
        
        assert isinstance(branch, (str, unicode)), branch
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/branches/" + branch
        )
        return github.Branch.Branch(self._requester, headers, data, completed=True)
253718
def get_branches(aliases):
    """"""

    ignore = ['pow', 'log10', 'sqrt', 'max']
    branches = []
    for k, v in aliases.items():

        tokens = re.sub('[\(\)\+\*\/\,\=\<\>\&\!\-\|]', ' ', v).split()

        for t in tokens:

            if bool(re.search(r'^\d', t)) or len(t) <= 3:
                continue

            if bool(re.search(r'[a-zA-Z]', t)) and t not in ignore:
                branches += [t]

    return list(set(branches))
838944
def branch(self, name, desc=None):
        
        return Local.new(path=os.path.join(self.path, name), desc=desc, bare=True)
11644
function getFileList(branchName = config.baseBranch) {
  logger.debug(`getFileList(${branchName})`);
  return config.storage.getFileList(branchName);
}
1219821
def bitbucket(branch: str):
    
    assert os.environ.get('BITBUCKET_BRANCH') == branch
    assert not os.environ.get('BITBUCKET_PR_ID')
648859
def handle_branch(repo, **kwargs):
    """"""
    log.info('branch: %s %s' %(repo, kwargs))
    if type(repo) in [unicode, str]:
        path = os.path.join(repo, kwargs.get('name', 'Unnamed'))
        desc = kwargs.get('desc')
        branch = Repo.new(path=path, desc=desc, bare=True)
    else:
        name = kwargs.get('name')
        path = kwargs.get('path')
        if path and not name:
            name = os.path.basename(path)
        desc = kwargs.get('desc')
        branch = repo.branch(name=name, desc=desc)
    return branch.serialize()
1150922
def get_server_build_info(self):
        
        if self.is_online():
            try:
                return self.get_mongo_client().server_info()
            except OperationFailure, ofe:
                log_exception(ofe)
                if "there are no users authenticated" in str(ofe):
                    # this is a pymongo 3.6.1 regression where the buildinfo command fails on non authenticated client
                    # fall-back to an authenticated client
                    admin_db = self.get_db("admin", no_auth=False)
                    return admin_db.command("buildinfo")
            except Exception, e:
                log_exception(e)

        return None
289014
def remote_for_branch(branch_name)
      git_call('branch -lvv').gsub('* ', '').split("\n").each do |line|
        entries = line.split(' ')
        next unless entries.first == branch_name
        # Return the remote name or nil for local branches.
        match = entries[2].match(%r(\[(.*)(\]|:)))
        return match[1].split('/').first if match
      end
      nil
    end
1086571
def get_branches(self, repo_slug=None):
        
        repo_slug = repo_slug or self.repo_slug or ''
        url = self.url('GET_BRANCHES',
                       username=self.username,
                       repo_slug=repo_slug)
        return self.dispatch('GET', url, auth=self.auth)
3032
def fetch_commits(local_root, remotes):
    
    # Fetch all known branches.
    command = ['git', 'fetch', 'origin']
    run_command(local_root, command)

    # Fetch new branches/tags.
    for sha, name, kind in remotes:
        try:
            run_command(local_root, ['git', 'reflog', sha])
        except CalledProcessError:
            run_command(local_root, command + ['refs/{0}/{1}'.format(kind, name)])
            run_command(local_root, ['git', 'reflog', sha])
581186
def get_ref(self, branch, origin=None):
        
        if not origin:
            origin = self.origin
        uri = "{api}/repos/{origin}/git/refs/heads/{branch}".format(
            api=self.github_api_url,
            origin=origin,
            branch=branch
        )
        data = self.request("GET", uri)
        if data.status_code == 200:
            data = json.loads(data.content.decode("utf-8"))
            if isinstance(data, list):
                # No addresses matches, we get search results which stars with {branch}
                return False
            #  Otherwise, we get one record
            return data["object"]["sha"]
        elif data.status_code == 404:
            return False
        else:
            decoded_data = json.loads(data.content.decode("utf-8"))
            return self.ProxyError(
                data.status_code, (decoded_data, "message"),
                step="get_ref", context={
                    "uri": uri
                }
            )
712287
def get_sys_info():
    ""

    blob = []

    # get full commit hash
    commit = None
    if os.path.isdir(".git") and os.path.isdir("pandas"):
        try:
            pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "),
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            so, serr = pipe.communicate()
        except (OSError, ValueError):
            pass
        else:
            if pipe.returncode == 0:
                commit = so
                try:
                    commit = so.decode('utf-8')
                except ValueError:
                    pass
                commit = commit.strip().strip('"')

    blob.append(('commit', commit))

    try:
        (sysname, nodename, release,
         version, machine, processor) = platform.uname()
        blob.extend([
            ("python", '.'.join(map(str, sys.version_info))),
            ("python-bits", struct.calcsize("P") * 8),
            ("OS", "{sysname}".format(sysname=sysname)),
            ("OS-release", "{release}".format(release=release)),
            # ("Version", "{version}".format(version=version)),
            ("machine", "{machine}".format(machine=machine)),
            ("processor", "{processor}".format(processor=processor)),
            ("byteorder", "{byteorder}".format(byteorder=sys.byteorder)),
            ("LC_ALL", "{lc}".format(lc=os.environ.get('LC_ALL', "None"))),
            ("LANG", "{lang}".format(lang=os.environ.get('LANG', "None"))),
            ("LOCALE", '.'.join(map(str, locale.getlocale()))),
        ])
    except (KeyError, ValueError):
        pass

    return blob
603546
def branch(self, branch_name, start_point='HEAD', force=True,
               checkout=False):
        
        return git_branch(
            self.repo_dir, branch_name, start_point, force=force,
            checkout=checkout)