Refactor gitCommitLink method to handle different git repository formats

This commit is contained in:
Andras Bacsai
2024-05-15 10:45:08 +02:00
parent 346faf1d07
commit cd3e2963b3
2 changed files with 34 additions and 13 deletions

View File

@@ -189,6 +189,17 @@ class Application extends BaseModel
}
);
}
public function gitCommitLink($link): string
{
if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {
return "{$this->source->html_url}/{$this->git_repository}/commit/{$link}";
}
if (strpos($this->git_repository, 'git@') === 0) {
$git_repository = str_replace(['git@', ':', '.git'], ['', '/', ''], $this->git_repository);
return "https://{$git_repository}/commit/{$link}";
}
return $this->git_repository;
}
public function dockerfileLocation(): Attribute
{
return Attribute::make(