Get monthly downloads badge image

@param Repo $repo
@return string
497943
public function getMonthlyDownloadBadge(Repo $repo)
    {
        if ($repo->getPackagistSlug()) {
            return sprintf('<img src="%s" />', $this->helper->getMonthlyDownloadBadgeUrl($repo->getPackagistSlug()));
        }

        return '';
    }
259153
public function create(string $repo, array $params = [])
    {
        $path = $this->buildUsersPath($repo);

        return $this->post($path, $params);
    }
411173
public function get($account, $repo, $linkID)
    {
        return $this->requestGet(
            sprintf('repositories/%s/%s/links/%d', $account, $repo, $linkID)
        );
    }
350857
public function getDailyDownloadBadge(Repo $repo)
    {
        if ($repo->getPackagistSlug()) {
            return sprintf('<img src="%s" />', $this->helper->getDailyDownloadBadgeUrl($repo->getPackagistSlug()));
        }

        return '';
    }
991306
public function getByTag($user, $repo, $tag)
	{
		// Build the request path.
		$path = "/repos/$user/$repo/releases/tags/$tag";

		// Send the request.
		return $this->processResponse($this->client->get($this->fetchUrl($path)));
	}
564325
public function getAsset($user, $repo, $assetId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId;

		// Send the request.
		return $this->processResponse($this->client->get($this->fetchUrl($path)));
	}
1145783
public function is_private( $repo ) {
		if ( ! isset( $repo->remote_version ) && ! self::is_doing_ajax() ) {
			return true;
		}
		if ( isset( $repo->remote_version ) && ! self::is_doing_ajax() ) {
			return ( '0.0.0' === $repo->remote_version ) || ! empty( self::$options[ $repo->slug ] );
		}

		return false;
	}
265040
public function loadPackagistInfos(Repo $repo)
    {
        try {
            $this->composerReader->load($repo->getSlug());

            // Load package name
            if ($this->composerReader->has('name')) {
                $repo->setPackagistSlug($this->composerReader->get('name'));
            }

            // Load authors
            if ($this->composerReader->has('authors')) {
                $repo->setAuthors($this->composerReader->get('authors'));
            }

            // Load dependencies
            if ($this->composerReader->has('require')) {
                $repo->setDependencies($this->composerReader->get('require'));
            }
        } catch (\Exception $e) {
            // We do not want to throw exception here!
        }
    }
1279551
protected function get_changelog_filename( $repo ) {
		$changelogs  = [ 'CHANGES.md', 'CHANGELOG.md', 'changes.md', 'changelog.md' ];
		$changes     = null;
		$local_files = null;

		if ( is_dir( $repo->local_path ) ) {
			$local_files = scandir( $repo->local_path, 0 );
		}

		$changes = array_intersect( (array) $local_files, $changelogs );
		$changes = array_pop( $changes );

		if ( ! empty( $changes ) ) {
			return $changes;
		}

		return false;
	}
877071
protected function _getConf($repo = null, $key = null, $_ = null)
    {
        // retrieve and cache config
        $services = $this->services();
        ($repo !== 'self') ?: $repo = $this->_getRepoKey();

        /** @var aSapi $config */
        $config = $services->get('/sapi');
        $config = $config->config();
        /** @var DataEntity $config */
        $config = $config->get(\Module\MongoDriver\Module::CONF_KEY, array());

        if (! isset($config[self::CONF_REPOSITORIES]) || !is_array($config[self::CONF_REPOSITORIES]) )
            return null;


        $config   = $config[self::CONF_REPOSITORIES];
        if (! isset($config[$repo]) )
            // Config not found for this repository
            return null;

        $config   = $config[$repo];



        ## Retrieve requested config key(s)
        #
        $keyconfs = func_get_args();
        array_shift($keyconfs);

        foreach ($keyconfs as $key) {
            if (! isset($config[$key]) )
                return null;

            $config = $config[$key];
        }

        return $config;
    }
1107333
function downloadUpdateRepo(config, callback) {

  console.log('Downloading repo...'.magenta);

  // Keep track if the request fails to prevent the continuation of the install
  var requestFailed = false;

  // TODO: have this hit different templating repos
  var repoRequest = request(config.baseGit + '/generate-repo.zip');

  repoRequest
    .on('response', function (response) {
      // If we fail, set it as failing and remove zip file
      if (response.statusCode !== 200) {
        requestFailed = true;
        fs.unlinkSync('.generate-repo.zip');
        callback(true);
      }
    })
    .pipe(fs.createWriteStream('.generate-repo.zip'))
    .on('close', function () {
      if (requestFailed) return;

      callback(null, '.generate-repo.zip');
    });
}
308912
private function getPackages(RepositoryInterface $repo)
    {
        $packages = [];

        if ($this->hasFilterForPackages()) {
            // apply package filter if defined
            foreach ($this->packagesFilter as $filter) {
                $packages += $repo->findPackages($filter);
            }
        } else {
            // process other repos directly
            $packages = $repo->getPackages();
        }

        return $packages;
    }
475530
private function getNamespace($repo)
    {
        $package = trim(ucfirst(S::create(
            str_replace(['.'], ['-'], basename($repo, '.git'))
        )->camelize()));

        $vendor = trim(ucfirst(S::create(
            str_replace(['.'], ['-'], basename(dirname($repo), '.git'))
        )->camelize()));

        return $vendor.'\\'.$package;
    }
853859
def repo_id(self, repo: str) -> str:
        
        if repo.startswith("http"):
            repo_id = re.sub(r"https?://(.www)?", "", repo)
            repo_id = re.sub(r"\.git/?$", "", repo_id)
        else:
            repo_id = repo.replace("file://", "")
            repo_id = re.sub(r"\.git/?$", "", repo_id)
            if repo_id.startswith("~"):
                repo_id = str(Path(repo_id).resolve())

        # replaces everything that isn't alphanumeric, a dot or an underscore
        # to make sure it's a valid folder name and to keep it readable
        # multiple consecutive invalid characters replaced with a single underscore
        repo_id = re.sub(r"[^a-zA-Z0-9._]+", "_", repo_id)

        # and add a hash of the original to make it absolutely unique
        return repo_id + hashlib.sha256(repo.encode("utf-8")).hexdigest()
631526
private function getPackageHandlesToTry(RemotePackageRepository $repo, DateTime $dateLimit)
    {
        $qb = $repo->createQueryBuilder('rp');
        $expr = $qb->expr();
        $qb
            ->distinct()
            ->select('rp.handle')
            ->where($expr->isNull('rp.processedOn'))
            ->andWhere($expr->eq('rp.approved', 0))
            ->andWhere($expr->gte('rp.createdOn', ':minCreatedOn'))->setParameter('minCreatedOn', $dateLimit)
        ;
        foreach ($qb->getQuery()->iterate() as $tryPackage) {
            $row = array_pop($tryPackage);
            yield $row['handle'];
        }
    }
55001
private function getCommits($org, $repo, $version)
    {
        $url = sprintf(
            self::GITHUB_COMPARE_ENDPOINT,
            $org,
            $repo,
            $version
        );

        $res = json_decode($this->http->get($url, [
            'auth' => [null, $this->token]
        ])->getBody(), true);
        $commits = [];
        foreach ($res['commits'] as $commit) {
            $message = $commit['commit']['message'];

            $description = explode("\n", $message)[0];
            $matches = [];
            if (preg_match('/(.{0,})\(\#(\d{1,})\)/', $description, $matches) === 1) {
                $message = trim($matches[1]);
                $prNumber = isset($matches[2]) ? $matches[2] : null;
            } else {
                $prNumber = $this->askForPrNumber($message);
            }

            if (strpos($message, '[CHANGE ME]') === 0 && $prNumber) {
                $message = $this->getMessageFromPullRequest($org, $repo, $prNumber);
            }

            $commits[] = [
                'url' => $commit['url'],
                'htmlUrl' => $commit['html_url'],
                'message' => $message,
                'reference' => $prNumber,
                'hash' => $commit['sha']
            ];
        }

        return $commits;
    }
501086
protected function return_repo_type() {
		$arr         = [];
		$arr['type'] = $this->type->type;

		switch ( $this->type->git ) {
			case 'github':
				$arr['git']           = 'github';
				$arr['base_uri']      = 'https://api.github.com';
				$arr['base_download'] = 'https://github.com';
				break;
			case 'bitbucket':
				$arr['git'] = 'bitbucket';
				if ( empty( $this->type->enterprise ) ) {
					$arr['base_uri']      = 'https://api.bitbucket.org';
					$arr['base_download'] = 'https://bitbucket.org';
				} else {
					$arr['base_uri']      = $this->type->enterprise_api;
					$arr['base_download'] = $this->type->enterprise;
				}
				break;
			case 'gitlab':
				$arr['git']           = 'gitlab';
				$arr['base_uri']      = 'https://gitlab.com/api/v4';
				$arr['base_download'] = 'https://gitlab.com';
				break;
			case 'gitea':
				$arr['git']           = 'gitea';
				$arr['base_uri']      = $this->type->enterprise . '/api/v1';
				$arr['base_download'] = $this->type->enterprise;
				break;
		}

		return $arr;
	}