Get information about the approvals present and required for a merge request
EE only.
509821
public GitlabMergeRequestApprovals getMergeRequestApprovals(GitlabMergeRequest mr) throws IOException {
        String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(mr.getProjectId()) +
                GitlabMergeRequest.URL + "/" + mr.getIid() + GitlabMergeRequestApprovals.URL;
        return retrieve().to(tailUrl, GitlabMergeRequestApprovals.class);
    }
1295723
def as_pull_request(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            "/pulls/".join(self.url.rsplit("/issues/", 1))
        )
        return github.PullRequest.PullRequest(self._requester, headers, data, completed=True)
143566
def is_merged(self):
        
        status, headers, data = self._requester.requestJson(
            "GET",
            self.url + "/merge"
        )
        return status == 204
341899
public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertificateRequest) {
        return mergeCertificate(mergeCertificateRequest.vaultBaseUrl(), mergeCertificateRequest.certificateName(),
                mergeCertificateRequest.x509Certificates(), mergeCertificateRequest.certificateAttributes(),
                mergeCertificateRequest.tags());
    }
643177
private void collectRequiredAddons(AddonInfo addonInfo, List<AddonInfo> addons)
   {
      // Move this addon to the top of the list
      addons.remove(addonInfo);
      addons.add(0, addonInfo);
      for (AddonId addonId : addonInfo.getRequiredAddons())
      {
         if (!addons.contains(addonId) && (!isDeployed(addonId) || !isEnabled(addonId)))
         {
            AddonInfo childInfo = info(addonId);
            collectRequiredAddons(childInfo, addons);
         }
      }
   }
886376
def runGetInfo(self, request):
        
        return protocol.toJson(protocol.GetInfoResponse(
            protocol_version=protocol.version))
1169275
def get_pull_requests(self):
        ""
        g = self.github
        query = {'state': 'all'}
        if self.args.github_token:
            query['access_token'] = g['token']

        def f(pull):
            if self.args.ignore_closed:
                return (pull['state'] == 'opened' or
                        (pull['state'] == 'closed' and pull['merged_at']))
            else:
                return True
        pulls = filter(f,
                       self.get(g['url'] + "/repos/" + g['repo'] + "/pulls",
                                query, self.args.cache))
        return dict([(str(pull['number']), pull) for pull in pulls])
316817
def BuildApprovalUrn(self, approval_id):
    """"""
    event = rdf_events.AuditEvent(
        user=self.token.username,
        action="CLIENT_APPROVAL_REQUEST",
        client=self.subject_urn,
        description=self.reason)
    events.Events.PublishEvent("Audit", event, token=self.token)

    return self.ApprovalUrnBuilder(self.subject_urn.Path(), self.token.username,
                                   approval_id)
896929
def CheckApprovalRequest(approval_request):
  """"""

  at = rdf_objects.ApprovalRequest.ApprovalType

  if approval_request.approval_type == at.APPROVAL_TYPE_CLIENT:
    return CheckClientApprovalRequest(approval_request)
  elif approval_request.approval_type == at.APPROVAL_TYPE_HUNT:
    return CheckHuntApprovalRequest(approval_request)
  elif approval_request.approval_type == at.APPROVAL_TYPE_CRON_JOB:
    return CheckCronJobApprovalRequest(approval_request)
  else:
    raise ValueError(
        "Invalid approval type: %s" % approval_request.approval_type)
981656
@Override
	public Collection<Approval> getApprovals(String userId, String clientId) {
		Collection<Approval> result = new HashSet<Approval>();
		Collection<OAuth2AccessToken> tokens = store.findTokensByClientIdAndUserName(clientId, userId);
		for (OAuth2AccessToken token : tokens) {
			OAuth2Authentication authentication = store.readAuthentication(token);
			if (authentication != null) {
				Date expiresAt = token.getExpiration();
				for (String scope : token.getScope()) {
					result.add(new Approval(userId, clientId, scope, expiresAt, ApprovalStatus.APPROVED));
				}
			}
		}
		return result;
	}
1164531
def get_protection(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.protection_url,
            headers={'Accept': Consts.mediaTypeRequireMultipleApprovingReviews}
        )
        return github.BranchProtection.BranchProtection(self._requester, headers, data, completed=True)
672098
def get_reqs(which="main"):
    """"""
    reqs = []
    for req in all_reqs[which]:
        req_str = req + ">=" + ver_tuple_to_str(min_versions[req])
        if req in version_strictly:
            req_str += ",<" + ver_tuple_to_str(min_versions[req][:-1]) + "." + str(min_versions[req][-1] + 1)
        reqs.append(req_str)
    return reqs
244682
def attempt_squash_merge(pr: PullRequestDetails
                         ) -> Union[bool, CannotAutomergeError]:
    
    url = ("https://api.github.com/repos/{}/{}/pulls/{}/merge"
           "?access_token={}".format(pr.repo.organization,
                                     pr.repo.name,
                                     pr.pull_id,
                                     pr.repo.access_token))
    data = {
        'commit_title': '{} (#{})'.format(pr.title, pr.pull_id),
        'commit_message': pr.body,
        'sha': pr.branch_sha,
        'merge_method': 'squash'
    }
    response = requests.put(url, json=data)

    if response.status_code == 200:
        # Merge succeeded.
        log('Merged PR#{} ({!r}):\n{}\n'.format(
            pr.pull_id,
            pr.title,
            indent(pr.body)))
        return True

    if response.status_code == 405:
        return CannotAutomergeError("Pull Request is not mergeable.")

    if response.status_code == 409:
        # Need to sync.
        return False

    raise RuntimeError('Merge failed. Code: {}. Content: {}.'.format(
        response.status_code, response.content))
414941
def _get_pull_requests(self):
        
        for pull in self.repo.pull_requests(
            state="closed", base=self.github_info["master_branch"], direction="asc"
        ):
            if self._include_pull_request(pull):
                yield pull
1112026
def check_can_approve(self, request, application, roles):
        
        try:
            authorised_persons = self.get_authorised_persons(application)
            authorised_persons.get(pk=request.user.pk)
            return True
        except Person.DoesNotExist:
            return False
391435
def get_commits(repo_dir, old_commit, new_commit, hide_merges=True):
    """"""
    repo = Repo(repo_dir)
    commits = repo.iter_commits(rev="{0}..{1}".format(old_commit, new_commit))
    if hide_merges:
        return [x for x in commits if not x.summary.startswith("Merge ")]
    else:
        return list(commits)
563348
def _retrieve_info(self, request):
        
        info = _metadata.get_service_account_info(
            request,
            service_account=self._service_account_email)

        self._service_account_email = info['email']
        self._scopes = info['scopes']