fix: bitbucket repository url

This commit is contained in:
Lorenzo Migliorero 2024-07-19 13:41:01 +02:00
parent c37398af72
commit 2dbba366b7
No known key found for this signature in database
GPG key ID: 9A9F1AD60C05DFE2

View file

@ -275,12 +275,20 @@ public function gitBranchLocation(): Attribute
return Attribute::make(
get: function () {
if (! is_null($this->source?->html_url) && ! is_null($this->git_repository) && ! is_null($this->git_branch)) {
if (str($this->git_repository)->contains('bitbucket')) {
return "{$this->source->html_url}/{$this->git_repository}/src/{$this->git_branch}";
}
return "{$this->source->html_url}/{$this->git_repository}/tree/{$this->git_branch}";
}
// Convert the SSH URL to HTTPS URL
if (strpos($this->git_repository, 'git@') === 0) {
$git_repository = str_replace(['git@', ':', '.git'], ['', '/', ''], $this->git_repository);
if (str($this->git_repository)->contains('bitbucket')) {
return "https://{$git_repository}/src/{$this->git_branch}";
}
return "https://{$git_repository}/tree/{$this->git_branch}";
}