@param string $user
@param string $repo
@param string $ref

@return string
430028
public function urlForReference(string $user, string $repo, string $ref): string
    {
        $key = sprintf(self::CACHE_KEY_TEMPLATE, md5($user . $repo), 'ref_url_' . md5($ref));

        if (($latest = $this->getFromCache($key)) !== null) {
            return $latest;
        }

        [$type, $resolved] = $this->resolveRefType($ref);
        $repoURL = $this->urlForRepository($user, $repo);

        switch ($type) {
            case 'commit':
                $url = "${repoURL}/commit/${resolved}";
                break;

            case 'tag':
                $url = "${repoURL}/releases/tag/${resolved}";
                break;

            case 'pull':
                $url = "${repoURL}/pull/${resolved}";
                break;

            case 'branch':
            default:
                $url = "${repoURL}/tree/${resolved}";
        }

        $this->setToCache($key, $url, 30);
        return $url;
    }
285006
public function getListContributors($owner, $repo, $anon = false)
	{
		// Build the request path.
		$uri = new Uri($this->fetchUrl('/repos/' . $owner . '/' . $repo . '/contributors'));

		if ($anon)
		{
			$uri->setVar('anon', 'true');
		}

		// Send the request.
		return $this->processResponse($this->client->get($uri));
	}
1184833
protected function parse_header_uri( $repo_header ) {
		$header_parts         = parse_url( $repo_header );
		$header_path          = pathinfo( $header_parts['path'] );
		$header['original']   = $repo_header;
		$header['scheme']     = isset( $header_parts['scheme'] ) ? $header_parts['scheme'] : null;
		$header['host']       = isset( $header_parts['host'] ) ? $header_parts['host'] : null;
		$header['owner']      = trim( $header_path['dirname'], '/' );
		$header['repo']       = $header_path['filename'];
		$header['owner_repo'] = implode( '/', [ $header['owner'], $header['repo'] ] );
		$header['base_uri']   = str_replace( $header_parts['path'], '', $repo_header );
		$header['uri']        = isset( $header['scheme'] ) ? trim( $repo_header, '/' ) : null;

		$header = $this->sanitize( $header );

		return $header;
	}
111855
public function pullRequest(string $user, string $repo, string $number): ?array
    {
        $api = $this->client->api('pull_request');
        $params = [$user, $repo, $number];

        $refs = $this->callGitHub([$api, 'show'], $params);

        return is_array($refs) ? $refs : null;
    }
63717
public function loadUser($user)
    {

        $ok = false;
        if (!empty($user->getRecordId())) {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (user_pk = %d)',
            $user->getRecordId());
        } else {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)',
                           $user->getResourceLink()->getRecordId(),
                           DataConnector::quoted($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY)));
        }
        $rsUser = mysql_query($sql);
        if ($rsUser) {
            $row = mysql_fetch_object($rsUser);
            if ($row) {
                $user->setRecordId(intval($row->user_pk));
                $user->setResourceLinkId(intval($row->resource_link_pk));
                $user->ltiUserId = $row->lti_user_id;
                $user->ltiResultSourcedId = $row->lti_result_sourcedid;
                $user->created = strtotime($row->created);
                $user->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }
336168
public function repository(string $user, string $repo): ?array
    {
        $api = $this->client->api('repo');
        $params = [$user, $repo];

        $repo = $this->callGitHub([$api, 'show'], $params);

        return is_array($repo) ? $repo : null;
    }
209589
public function remove($username, $repository, $reference)
    {
        $reference = $this->encodeReference($reference);

        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference);
    }
330996
protected function getUserLink(User $user = null)
    {
        if (!$user) {
            return '<strong>' . t('Deleted User') . '</strong>';
        }

        $link = $this->getUrlResolver()->resolve(['/dashboard/users/search', $user->getUserID()]);
        $name = h($user->getUserName());
        return "<a href='$link'><strong>$name</strong></a>";
    }
212329
public function load(Repo $repo)
    {
        $scrutinizerRepo = $this->client->fetchRepository(new Repository($repo->getSlug(), $repo->getType()));

        if ($scrutinizerRepo) {
            // Inject scrutinizer data into repository
            $repo->setMetrics($scrutinizerRepo->getMetrics());
            $repo->setPdependMetrics($scrutinizerRepo->getPdependMetrics());
        }

        return $repo;
    }
691440
public function detachMember(User $user,
        /** @noinspection PhpUnusedParameterInspection */
                                   MemberTag $memberTag,
                                   $memberId)
    {
        return $user->selected_context->id === $memberId;
    }
158974
public function get_remote_repo_meta( $repo ) {
		$file = 'style.css';
		if ( false !== stripos( $repo->type, 'plugin' ) ) {
			$file = basename( $repo->file );
		}

		$repo_api = Singleton::get_instance( 'API', $this )->get_repo_api( $repo->git, $repo );
		if ( null === $repo_api ) {
			return false;
		}

		$this->{$repo->type} = $repo;
		$this->set_defaults( $repo->type );

		if ( $repo_api->get_remote_info( $file ) ) {
			if ( ! self::is_wp_cli() ) {
				if ( ! apply_filters( 'github_updater_run_at_scale', false ) ) {
					$repo_api->get_repo_meta();
					$changelog = $this->get_changelog_filename( $repo );
					if ( $changelog ) {
						$repo_api->get_remote_changes( $changelog );
					}
					$repo_api->get_remote_readme();
				}
				if ( ! empty( self::$options['branch_switch'] ) ) {
					$repo_api->get_remote_branches();
				}
			}
			$repo_api->get_remote_tag();
			$repo->download_link = $repo_api->construct_download_link();
			$language_pack       = new Language_Pack( $repo, new Language_Pack_API( $repo ) );
			$language_pack->run();
		}

		$this->remove_hooks( $repo_api );

		return true;
	}
936058
public RepositoryDTO getOrFindUserRepository(String user, String repositoryName, GitRepoClient repoClient) {
        RepositoryDTO repository = getUserRepository(user, repositoryName);
        if (repository == null) {
            List<RepositoryDTO> repositoryDTOs = repoClient.listRepositories();
            updateUserRepositories(repositoryDTOs);
            repository = getUserRepository(user, repositoryName);
        }
        return repository;
    }
436880
private function serializePicture(User $user)
    {
        if (!empty($user->getPicture())) {
            /** @var PublicFile $file */
            $file = $this->om
                ->getRepository(PublicFile::class)
                ->findOneBy(['url' => $user->getPicture()]);

            if ($file) {
                return $this->fileSerializer->serialize($file);
            }
        }

        return null;
    }
921167
public function getTheReadme($owner, $repo, $ref = null)
	{
		$data = array();
		if(!is_null($ref))
			$data['ref'] = $ref;
		
		return $this->client->request("/repos/$owner/$repo/readme", 'GET', $data, 200, 'GitHubRepoContent');
	}
864693
public function repoGetFileContent($repo, $path, $ref = null)
    {
        $src = $this->client->api('Repositories\Src');

        $response = $this->checkResponse($src->raw($this->username, $repo, $ref, $path));

        return $response->getContent();
    }
891514
public function replaceUser(User $from, User $to)
    {
        $marks = $this->repo->findByUser($from);

        if (count($marks) > 0) {
            foreach ($marks as $mark) {
                $mark->setUser($to);
            }

            $this->om->flush();
        }

        return count($marks);
    }
556473
public function repoList($repo, $path = null, $ref = null)
    {
        $src = $this->client->api('Repositories\Src');
        /** @var \Buzz\Message\Response $response */
        $response = $this->checkResponse($src->get($this->username, $repo, $ref, $path));

        return $this->cleanSrcList(json_decode($response->getContent(), true));
    }