Get the OSA sha referenced by an RPCO Repo.
439139
def get_osa_commit(repo, ref, rpc_product=None):
    """"""
    osa_differ.checkout(repo, ref)

    functions_path = os.path.join(repo.working_tree_dir,
                                  'scripts/functions.sh')
    release_path = os.path.join(repo.working_tree_dir,
                                'playbooks/vars/rpc-release.yml')

    if os.path.exists(release_path):
        with open(release_path) as f:
            rpc_release_data = yaml.safe_load(f.read())

        rpc_product_releases = rpc_release_data['rpc_product_releases']
        release_data = rpc_product_releases[rpc_product]

        return release_data['osa_release']

    elif repo.submodules['openstack-ansible']:
        return repo.submodules['openstack-ansible'].hexsha

    elif os.path.exists(functions_path):
        # This branch doesn't use a submodule for OSA
        # Pull the SHA out of functions.sh
        quoted_re = re.compile('OSA_RELEASE:-?"?([^"}]+)["}]')
        with open(functions_path, "r") as funcs:
            for line in funcs.readlines():
                match = quoted_re.search(line)
                if match:
                    return match.groups()[0]
            else:
                raise SHANotFound(
                    ("Cannot find OSA SHA in submodule or "
                     "script: {}".format(functions_path)))

    else:
        raise SHANotFound('No OSA SHA was able to be derived.')
75857
def get_git_commit(self, sha):
        
        assert isinstance(sha, (str, unicode)), sha
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/git/commits/" + sha
        )
        return github.GitCommit.GitCommit(self._requester, headers, data, completed=True)
1101200
def version(self):
        

        resp = self.call('version')

        for key in ('rpc_version', 'store_version'):
            resp[key] = int(resp[key])

        return resp
341756
def _get_ref_info_helper(cls, repo, ref_path):
        """"""
        tokens = None
        repodir = _git_dir(repo, ref_path)
        try:
            with open(osp.join(repodir, ref_path), 'rt') as fp:
                value = fp.read().rstrip()
            # Don't only split on spaces, but on whitespace, which allows to parse lines like
            # 60b64ef992065e2600bfef6187a97f92398a9144                branch 'master' of git-server:/path/to/repo
            tokens = value.split()
            assert(len(tokens) != 0)
        except (OSError, IOError):
            # Probably we are just packed, find our entry in the packed refs file
            # NOTE: We are not a symbolic ref if we are in a packed file, as these
            # are excluded explicitly
            for sha, path in cls._iter_packed_refs(repo):
                if path != ref_path:
                    continue
                # sha will be used
                tokens = sha, path
                break
            # END for each packed ref
        # END handle packed refs
        if tokens is None:
            raise ValueError("Reference at %r does not exist" % ref_path)

        # is it a reference ?
        if tokens[0] == 'ref:':
            return (None, tokens[1])

        # its a commit
        if repo.re_hexsha_only.match(tokens[0]):
            return (tokens[0], None)

        raise ValueError("Failed to parse reference information from %r" % ref_path)
911563
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        try:
            metrics_context = hmc.lookup_by_uri(uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        result = metrics_context.get_metric_values_response()
        return result
1346887
function getFileUrl (repo, path, sha, line) {
  return HOST + "/" + repo + "/src/" + sha + "/" + path + "#cl-" + line;
}
400665
def _get_repo():
    """"""
    command = ['git', 'rev-parse', '--show-toplevel']
    if six.PY2:
        try:
            return check_output(command).decode('utf-8').strip()    # nosec
        except CalledProcessError:
            return ''
    else:
        return (run(command, stdout=PIPE, stderr=PIPE)
                .stdout.decode('utf-8').strip())
994540
def get_sha(path=None, log=None, short=False, timeout=None):
    
    # git_command = "git rev-parse HEAD {}".format(repo_name).split()
    # git_command = "git rev-parse HEAD".split()
    git_command = ["git", "rev-parse"]
    if short:
        git_command.append("--short")
    git_command.append("HEAD")

    kwargs = {}
    if path is not None:
        kwargs['cwd'] = path
    if timeout is not None:
        kwargs['timeout'] = timeout

    if log is not None:
        log.debug("{} {}".format(git_command, str(kwargs)))

    sha = subprocess.check_output(git_command, **kwargs)
    try:
        sha = sha.decode('ascii').strip()
    except:
        if log is not None:
            log.debug("decode of '{}' failed".format(sha))

    return sha
1071054
async function getRev(rev, currentRev, client, config) {
  var revHash = rev.substr(config.indexKey.indexOf('%s'));
  if (revHash === 'current') return;

  var str = revHash === currentRev ? rev + ' (current)' : rev;
  try {
    const commitData = await gitlog({
      repo: path.resolve(process.cwd(), '.git'),
      number: 1,
      fields: [
        'abbrevHash',
        'subject',
        'committerDate',
        'committerDateRel',
        'authorName',
        'hash',
      ],
      branch: revHash,
    });
    if (!commitData.length) {
      return;
    }

    const firstCommitData = commitData[0];

    const metadata = await client.get(util.format(config.metaKey, revHash));
    if (!metadata) {
      gutil.log(gutil.colors.red('Cannot retrieve metadata'));
      return;
    }

    return [
      new Date(firstCommitData.committerDate),
      gutil.colors.yellow(str),
      firstCommitData.subject,
      gutil.colors.white(firstCommitData.committerDateRel),
      gutil.colors.white.blue('<' + firstCommitData.authorName + '>'),
      (metadata && gutil.colors.white.blue(metadata)) || '',
    ];
  } catch (e) {
    if (e.toString().indexOf('unknown revision') > 0) {
      return [
        0,
        gutil.colors.yellow(str),
        gutil.colors.red('Unknown revision'),
      ];
    }
    gutil.log(gutil.colors.yellow(str));
    gutil.log(gutil.colors.red('Error:'), e);
  }
}
1117322
def get_repo(self, cached=True):
        """"""
        module = sys.modules[self.__module__]
        # We use module.__file__ instead of module.__path__[0]
        # to include modules without a __path__ attribute.
        if hasattr(self.__class__, '_repo') and cached:
            repo = self.__class__._repo
        elif hasattr(module, '__file__'):
            path = os.path.realpath(module.__file__)
            try:
                repo = git.Repo(path, search_parent_directories=True)
            except InvalidGitRepositoryError:
                repo = None
        else:
            repo = None
        self.__class__._repo = repo
        return repo
1273889
protected function getRepositoryReference(Adapter $adapter, $org, $repo)
    {
        $remote = $this->findRemoteName(false);
        $repoInfo = $this->gitConfigHelper->getRemoteInfo($remote);

        if (null === $org) {
            $org = $repoInfo['vendor'];
        }

        if (null === $repo) {
            $repo = $repoInfo['repo'];
        }

        $adapterRepoInfo = $adapter->getRepositoryInfo($org, $repo);

        if ($adapterRepoInfo['is_fork']) {
            $org = $adapterRepoInfo['fork_origin']['org'];
            $repo = $adapterRepoInfo['fork_origin']['repo'];
        }

        return [$org, $repo];
    }
664638
final WsResource getLTPAKeyFileResource(WsLocationAdmin locService, String ltpaKeyFile) {
        WsResource ltpaFile = locService.resolveResource(ltpaKeyFile);
        if (ltpaFile != null && ltpaFile.exists()) {
            return ltpaFile;
        } else {
            // The file does not exist so return null
            return null;
        }
    }
295468
def _get_operation_rpc(self):
        
        request_pb = operations_pb2.GetOperationRequest(name=self.name)
        return self.client._operations_stub.GetOperation(request_pb)
1331764
def commit(self, sha):
        
        url = self._build_url('commits', sha, base_url=self._api)
        json = self._json(self._get(url), 200)
        return RepoCommit(json, self) if json else None
706437
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        query_str = uri_parms[0]
        try:
            console = hmc.consoles.lookup_by_oid(None)
        except KeyError:
            raise InvalidResourceError(method, uri)
        result_ldap_srv_defs = []
        filter_args = parse_query_parms(method, uri, query_str)
        for ldap_srv_def in console.ldap_server_definitions.list(filter_args):
            result_ldap_srv_def = {}
            for prop in ldap_srv_def.properties:
                if prop in ('element-uri', 'name', 'type'):
                    result_ldap_srv_def[prop] = ldap_srv_def.properties[prop]
            result_ldap_srv_defs.append(result_ldap_srv_def)
        return {'ldap-server-definitions': result_ldap_srv_defs}
1367446
def make_rpc_report(repo_dir, old_commit, new_commit,
                    args):
    """"""

    # Do we have a valid commit range?
    # NOTE:
    # An exception is thrown by osa_differ if these two commits
    # are the the same, but it is sometimes necessary to compare
    # two RPC tags that have the same OSA SHA. For example,
    # comparing two tags that only have differences between the
    # two RPCO commit, but no differences between the OSA SHAs
    # that correspond to those two commits.
    # To handle this case, the exception will be caught and flow
    # of execution will continue normally.
    try:
        osa_differ.validate_commit_range(repo_dir, old_commit, new_commit)
    except exceptions.InvalidCommitRangeException:
        pass

    # Get the commits in the range
    commits = osa_differ.get_commits(repo_dir, old_commit, new_commit)

    # Start off our report with a header and our OpenStack-Ansible commits.
    template_vars = {
        'args': args,
        'repo': 'rpc-openstack',
        'commits': commits,
        'commit_base_url': osa_differ.get_commit_url(args.rpc_repo_url),
        'old_sha': old_commit,
        'new_sha': new_commit
    }
    return render_template('offline-header.j2', template_vars)
452945
def get_revision_sha(self, dest, rev):
        
        # Pass rev to pre-filter the list.
        output = self.run_command(['show-ref', rev], cwd=dest,
                                  show_stdout=False, on_returncode='ignore')
        refs = {}
        for line in output.strip().splitlines():
            try:
                sha, ref = line.split()
            except ValueError:
                # Include the offending line to simplify troubleshooting if
                # this error ever occurs.
                raise ValueError('unexpected show-ref line: {!r}'.format(line))

            refs[ref] = sha

        branch_ref = 'refs/remotes/origin/{}'.format(rev)
        tag_ref = 'refs/tags/{}'.format(rev)

        sha = refs.get(branch_ref)
        if sha is not None:
            return (sha, True)

        sha = refs.get(tag_ref)

        return (sha, False)