From f71861300a9c696abe076c61b0e137011f7f94bb Mon Sep 17 00:00:00 2001 From: Tom Ferriere Date: Sun, 7 Jul 2024 10:01:11 +0200 Subject: [PATCH 1/3] fix: gitea pr previews --- app/Models/Application.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Models/Application.php b/app/Models/Application.php index 9c27fc938..7997d671f 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -817,6 +817,14 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); + } elseif ($git_type === 'gitea') { + $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; + if ($exec_in_docker) { + $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); + } else { + $commands->push("echo 'Checking out $branch'"); + } + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); } elseif ($git_type === 'bitbucket') { if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); @@ -861,6 +869,14 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); + } elseif ($git_type === 'gitea') { + $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; + if ($exec_in_docker) { + $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); + } else { + $commands->push("echo 'Checking out $branch'"); + } + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); } elseif ($git_type === 'bitbucket') { if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); From 2dfe43fc3c405650ce9d2fd50ca949443abf78b6 Mon Sep 17 00:00:00 2001 From: Xiloe Date: Sun, 7 Jul 2024 08:02:36 +0000 Subject: [PATCH 2/3] Fix styling --- app/Models/Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index 7997d671f..85e5bb1ba 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -817,7 +817,7 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'gitea') { + } elseif ($git_type === 'gitea') { $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); @@ -869,7 +869,7 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'gitea') { + } elseif ($git_type === 'gitea') { $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); From 01abc2631684da53645cecdfb7abb29a89a3b6a9 Mon Sep 17 00:00:00 2001 From: Tom Ferriere Date: Sun, 7 Jul 2024 10:40:05 +0200 Subject: [PATCH 3/3] removed redundant if statement --- app/Models/Application.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index 85e5bb1ba..84489ae7b 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -809,7 +809,7 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'github') { + } elseif ($git_type === 'github' || $git_type === 'gitea') { $branch = "pull/{$pull_request_id}/head:$pr_branch_name"; if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); @@ -817,14 +817,6 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'gitea') { - $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; - if ($exec_in_docker) { - $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); - } else { - $commands->push("echo 'Checking out $branch'"); - } - $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); } elseif ($git_type === 'bitbucket') { if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); @@ -861,7 +853,7 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'github') { + } elseif ($git_type === 'github' || $git_type === 'gitea') { $branch = "pull/{$pull_request_id}/head:$pr_branch_name"; if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); @@ -869,14 +861,6 @@ public function generateGitImportCommands(string $deployment_uuid, int $pull_req $commands->push("echo 'Checking out $branch'"); } $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); - } elseif ($git_type === 'gitea') { - $branch = "pulls/{$pull_request_id}/head:$pr_branch_name"; - if ($exec_in_docker) { - $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'")); - } else { - $commands->push("echo 'Checking out $branch'"); - } - $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name); } elseif ($git_type === 'bitbucket') { if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'"));