From 1988c617a0c76b58045e8a035f297c2b04347622 Mon Sep 17 00:00:00 2001 From: Lucas Heinschke Date: Fri, 10 May 2024 16:28:14 +0200 Subject: [PATCH] Correct repository links in source view for git SSH URLs --- app/Models/Application.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index 1ce33cefb..d84c4af39 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -146,9 +146,13 @@ class Application extends BaseModel 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}/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); + return "https://{$git_repository}/tree/{$this->git_branch}"; + } return $this->git_repository; } - ); } @@ -159,6 +163,11 @@ class Application extends BaseModel 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}/settings/hooks"; } + // Convert the SSH URL to HTTPS URL + if (strpos($this->git_repository, 'git@') === 0) { + $git_repository = str_replace(['git@', ':', '.git'], ['', '/', ''], $this->git_repository); + return "https://{$git_repository}/settings/hooks"; + } return $this->git_repository; } ); @@ -171,6 +180,11 @@ class Application extends BaseModel 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}/commits/{$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); + return "https://{$git_repository}/commits/{$this->git_branch}"; + } return $this->git_repository; } );