protected function generateBaseUrl($sourceUrl)
    {
        if ($this->isSshUrl($sourceUrl)) {
            return $this->transformSshUrlIntoHttp($sourceUrl);
        }

        $sourceUrl = parse_url($sourceUrl);
        $pos = strrpos($sourceUrl['path'], '.git');

        return sprintf(
            '%s://%s%s',
            $sourceUrl['scheme'],
            $sourceUrl['host'],
            $pos === false ? $sourceUrl['path'] : substr($sourceUrl['path'], 0, strrpos($sourceUrl['path'], '.git'))
        );
    }