From b4a7d5417ce1f86460fa376027be1eeff1c05e3a Mon Sep 17 00:00:00 2001 From: nicolly015 Date: Wed, 8 May 2024 17:20:44 -0300 Subject: [PATCH] Listagem das branchs e git checkout adicionado --- html/configuracao/atualizacao.php | 2 +- html/configuracao/debug_info.php | 104 +++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/html/configuracao/atualizacao.php b/html/configuracao/atualizacao.php index 373e7a58..aefda592 100755 --- a/html/configuracao/atualizacao.php +++ b/html/configuracao/atualizacao.php @@ -27,7 +27,7 @@ "./debug_info.php" ]); - $redirect = $_GET["redirect"] ?? REDIRECT[0]; + $redirect = $_GET["redirect"] ?? REDIRECT[1]; function tempBackup() { if (PHP_OS != 'Linux'){ diff --git a/html/configuracao/debug_info.php b/html/configuracao/debug_info.php index 1fadf577..e9d73aa7 100755 --- a/html/configuracao/debug_info.php +++ b/html/configuracao/debug_info.php @@ -16,7 +16,57 @@ } $conexao = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); + // Função para obter as branches de um repositório no GitHub usando a API + function getGitHubBranches($owner, $repo) + { + $url = "https://api.github.com/repos/$owner/$repo/branches"; + $options = [ + 'http' => [ + 'header' => "User-Agent: My-App\r\n", + ], + ]; + $context = stream_context_create($options); + $response = file_get_contents($url, false, $context); + return json_decode($response, true); + } + + function getCurrentBranch() { + $output = array(); + exec("git -C ".ROOT." branch | grep '*' | cut -d ' ' -f2", $output); + return $output[0]; + } + // Função para fazer o checkout para uma branch + function gitCheckout($branch) { + $output = array(); + exec("git -C ".ROOT." checkout $branch", $output); + return $output; + } + + // Obtém as branches do repositório + $owner = "nilsonLazarin"; + $repo = "WeGIA"; + $branches = []; + try { + $branchesData = getGitHubBranches($owner, $repo); + foreach ($branchesData as $branch) { + $branches[] = $branch['name']; + } + } catch (Exception $e) { + echo "Erro ao obter as branches do GitHub: " . $e->getMessage(); + } + + + if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['branch'])) { + $branch = $_POST['branch']; + $action = $_POST["action"]; + + if ($action == "switch") { + $output = gitCheckout($branch); + } elseif ($action == "update") { + header("Location: atualizacao.php?branch=$branch"); + } + } // Verifica Permissão do Usuário require_once '../permissao/permissao.php'; @@ -110,6 +160,44 @@ .btn{ width: 10%; } + + .config-item { + margin: 20px 0; + } + + .config-item form { + display: flex; + align-items: center; + } + + .config-item label, + .config-item select, + .config-item button { + margin: 0 10px; + } + + .config-item button { + background-color: #4CAF50; /* Verde */ + border: none; + color: white; + padding: 15px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + transition-duration: 0.4s; + cursor: pointer; + + border-radius: 12px; + + width: 150px; + } + + .config-item button:hover { + background-color: #45a049; + + transform: scale(1.1); + } @@ -192,9 +280,19 @@ ?>

-
-
Atualizar sistema para versão em desenvolvimento:
- +
+
Atualizar sistema para versão em desenvolvimento:
+
+ + + + +
+