Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor: Update gitCommitLink method to handle null values in source.html_url

Andras Bacsai28522418ffa7
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 859abe191c..50c7760ff6 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -228,7 +228,7 @@ 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)) {
+ if (! is_null(data_get($this, 'source.html_url')) && ! is_null(data_get($this, 'git_repository')) && ! is_null(data_get($this, 'git_branch'))) {
if (str($this->source->html_url)->contains('bitbucket')) {
return "{$this->source->html_url}/{$this->git_repository}/commits/{$link}";
}
@@ -245,8 +245,11 @@ class Application extends BaseModel
}
if (strpos($this->git_repository, 'git@') === 0) {
$git_repository = str_replace(['git@', ':', '.git'], ['', '/', ''], $this->git_repository);
+ if (data_get($this, 'source.html_url')) {
+ return "{$this->source->html_url}/{$git_repository}/commit/{$link}";
+ }
- return "https://{$git_repository}/commit/{$link}";
+ return "{$git_repository}/commit/{$link}";
}
return $this->git_repository;