<commit_before><?php
namespace AndKirby\Composer\MultiRepo\Repository\Vcs;

use Composer\Repository\Vcs\GitDriver;

class GitLabDriver extends GitDriver
{
    /**
     * Get GitLab archive info
     *
     * @param string $identifier
     * @return array
     */
    public function getDist($identifier)
    {
        return array(
            'type'   => 'tar',
            'url'    => $this->_getBranchTarArchiveUrl($identifier),
            'shasum' => ''
        );
    }

    /**
     * Get branch or tag TAR archive URL
     *
     * @param string $branchOrTag
     * @return string
     */
    protected function _getBranchTarArchiveUrl($branchOrTag)
    {
        return $this->getUrl() . '/repository/archive.tar.gz?ref=' . $branchOrTag;
    }

}<commit_msg>Fixed generating GitLab dist archive URLs.<commit_after><?php
namespace AndKirby\Composer\MultiRepo\Repository\Vcs;

use Composer\Repository\Vcs\GitDriver;

class GitLabDriver extends GitDriver
{
    /**
     * Get GitLab archive info
     *
     * @param string $identifier
     * @return array
     */
    public function getDist($identifier)
    {
        return array(
            'type'   => 'tar',
            'url'    => $this->_getBranchTarArchiveUrl(
                            $this->_getBranchNameByHash($identifier)
                        ),
            'reference' => $identifier,
            'shasum' => ''
        );
    }

    /**
     * Get branch or tag TAR archive URL
     *
     * @param string $branchOrTag
     * @return string
     */
    protected function _getBranchTarArchiveUrl($branchOrTag)
    {
        return $this->_getBaseArchiveUrl() . '/repository/archive?ref=' . $branchOrTag;
    }

    /**
     * Get branch or tag name by commit hash
     *
     * @param string $hash
     * @return mixed
     */
    protected function _getBranchNameByHash($hash)
    {
        $name = array_search($hash, $this->getTags());
        if (!$name) {
            $name = array_search($hash, $this->getBranches());
        }
        return $name;
    }

    /**
     * Get base GitLab archive URL
     *
     * @return string
     */
    protected function _getBaseArchiveUrl()
    {
        $url = $this->getUrl();
        if ('.git' == substr($url, -4)) {
            return substr($url, 0, -4);
        }
        return $url;
    }

}
{'fraction_non_alphanumeric': 0.12516129032258064, 'fraction_numerical': 0.0012903225806451613, 'mean_word_length': 1.88944099378882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6613833', 'n_tokens_mistral': 706, 'n_tokens_neox': 692, 'n_words': 150}