fix: sentry bug

This commit is contained in:
Andras Bacsai 2023-09-01 11:35:33 +02:00
parent 71e1571c39
commit 66162966b9
2 changed files with 15 additions and 13 deletions

View File

@ -39,7 +39,7 @@ class PublicGitRepository extends Component
'publish_directory' => 'publish directory', 'publish_directory' => 'publish directory',
]; ];
private object $repository_url_parsed; private object $repository_url_parsed;
private GithubApp|GitlabApp $git_source; private GithubApp|GitlabApp|null $git_source = null;
private string $git_host; private string $git_host;
private string $git_repository; private string $git_repository;
@ -67,18 +67,17 @@ class PublicGitRepository extends Component
public function load_branch() public function load_branch()
{ {
try {
$this->branch_found = false; $this->branch_found = false;
$this->validate([ $this->validate([
'repository_url' => 'required|url' 'repository_url' => 'required|url'
]); ]);
$this->get_git_source(); $this->get_git_source();
try {
$this->get_branch(); $this->get_branch();
$this->selected_branch = $this->git_branch; $this->selected_branch = $this->git_branch;
} catch (\Exception $e) { } catch (\Exception $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
if (!$this->branch_found && $this->git_branch == 'main') { if (!$this->branch_found && $this->git_branch == 'main') {
try { try {
$this->git_branch = 'master'; $this->git_branch = 'master';
@ -103,6 +102,9 @@ class PublicGitRepository extends Component
} elseif ($this->git_host == 'bitbucket.org') { } elseif ($this->git_host == 'bitbucket.org') {
// Not supported yet // Not supported yet
} }
if (is_null($this->git_source)) {
throw new \Exception('Git source not found. What?!');
}
} }
private function get_branch() private function get_branch()