本文整理匯總了PHP中PhabricatorRepository::canUseGitLFS方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorRepository::canUseGitLFS方法的具體用法?PHP PhabricatorRepository::canUseGitLFS怎麽用?PHP PhabricatorRepository::canUseGitLFS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhabricatorRepository
的用法示例。
在下文中一共展示了PhabricatorRepository::canUseGitLFS方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateGitLFSRequest
private function validateGitLFSRequest(PhabricatorRepository $repository, PhabricatorUser $viewer)
{
if (!$this->getIsGitLFSRequest()) {
return null;
}
if (!$repository->canUseGitLFS()) {
return new PhabricatorVCSResponse(403, pht('The requested repository ("%s") does not support Git LFS.', $repository->getDisplayName()));
}
// If this is using an LFS token, sanity check that we're using it on the
// correct repository. This shouldn't really matter since the user could
// just request a proper token anyway, but it suspicious and should not
// be permitted.
$token = $this->getGitLFSToken();
if ($token) {
$resource = $token->getTokenResource();
if ($resource !== $repository->getPHID()) {
return new PhabricatorVCSResponse(403, pht('The authentication token provided in the request is bound to ' . 'a different repository than the requested repository ("%s").', $repository->getDisplayName()));
}
}
return null;
}
示例2: getGitLFSRef
private function getGitLFSRef(PhabricatorRepository $repository, $data)
{
if (!$repository->canUseGitLFS()) {
return null;
}
$lfs_pattern = '(^version https://git-lfs\\.github\\.com/spec/v1[\\r\\n])';
if (!preg_match($lfs_pattern, $data)) {
return null;
}
$matches = null;
if (!preg_match('(^oid sha256:(.*)$)m', $data, $matches)) {
return null;
}
$hash = $matches[1];
$hash = trim($hash);
return id(new PhabricatorRepositoryGitLFSRefQuery())->setViewer($this->getViewer())->withRepositoryPHIDs(array($repository->getPHID()))->withObjectHashes(array($hash))->executeOne();
}