From 36b06aef96b6031e5fd6ac063e1425040036e0ab Mon Sep 17 00:00:00 2001 From: Benjamin Blake Date: Tue, 25 Feb 2020 12:32:07 -0700 Subject: [PATCH] Updated the TestRun file + Added several more tests --- src/TestRun.php | 91 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 10 deletions(-) diff --git a/src/TestRun.php b/src/TestRun.php index e10472f..5c03e02 100644 --- a/src/TestRun.php +++ b/src/TestRun.php @@ -22,18 +22,89 @@ $giteaClient->setAuthToken('32e609ad39539c1d0e8544800bd49b1025ac6b49'); // } else { // print("No Data could be retrieved"."\n"); // } -print("Getting all repos via API \n"); -$repositories = $giteaClient->repositories()->all(); -if ($repositories && count($repositories) > 0) { - foreach ($repositories as $item) { - print("Name: ".$item->getName()."\n"); - print("Full Name: ".$item->getFullName()."\n"); - print("Description: ".$item->getDescription()."\n"); - print("\n\n"); + +// print("Getting all repos via API \n"); +// $repositories = $giteaClient->repositories()->all(); +// if ($repositories && count($repositories) > 0) { +// foreach ($repositories as $item) { +// print("Name: ".$item->getName()."\n"); +// print("Full Name: ".$item->getFullName()."\n"); +// print("Description: ".$item->getDescription()."\n"); +// print("\n\n"); +// } +// print("Total Items: ".count($repositories)."\n"); +// } else { +// print("No repos could be retrieved"."\n"); +// } + +// print("Getting all tags for the 'sl-product-catalog' repository \n\n"); +// $repository = $giteaClient->repositories()->getByName("Sitelease", "sl-product-catalog"); +// if ($repository) { +// $tags = $repository->tags(); +// if ($tags && count($tags) > 0) { +// foreach ($tags as $tag) { +// var_dump(json_encode($tag)); +// print("\n\n"); +// } +// print("Total Tags: ".count($tags)."\n"); +// } +// } else { +// print("The repository could not be retrieved"."\n"); +// } + +// print("Getting all branches for the 'sl-product-catalog' repository \n\n"); +// $repository = $giteaClient->repositories()->getByName("Sitelease", "sl-theme-recipe"); +// if ($repository) { +// $branches = $repository->branches(); +// if ($branches && count($branches) > 0) { +// //foreach ($branches as $branch) { +// var_dump($branches->getItem("master")); +// print("\n\n"); +// //} +// print("Total Branches: ".count($branches)."\n"); +// } +// } else { +// print("The repository could not be retrieved"."\n"); +// } + +// print("Getting contents of \"composer.json\" file \n\n"); +// $rawFile = $giteaClient->repositories()->getRawFile("Sitelease", "sl-theme-recipe", "composer.json"); +// if ($rawFile) { +// var_dump(json_encode($rawFile)); +// print("\n\n"); +// } else { +// print("The raw file could not be retrieved"."\n"); +// } + +// print("Getting contents of \"composer.json\" file \n\n"); +// $rawFile = $giteaClient->repositories()->getRawFile("Sitelease", "sl-theme-recipe", "composer.json"); +// if ($rawFile) { +// var_dump($rawFile); +// print("\n\n"); +// } else { +// print("The raw file could not be retrieved"."\n"); +// } + +// print("Getting a repository \n\n"); +// $repository = $giteaClient->repositories()->getByName("Sitelease", "sl-theme-recipe"); +// if ($repository) { +// var_dump($repository); +// print("\n\n"); +// } else { +// print("The repository could not be retrieved"."\n"); +// } + +print("Getting archive for the 'sl-product-catalog' repository \n\n"); +$repository = $giteaClient->repositories()->getByName("Sitelease", "sl-theme-recipe"); +if ($repository) { + $archive = $repository->archive("master"); + if ($archive) { + print("Downloading Archive...\n"); + file_put_contents("master.tar.gz", $archive); + print("Success!\n"); } - print("Total Items: ".count($repositories)."\n"); } else { - print("No repos could be retrieved"."\n"); + print("The archive could not be retrieved"."\n"); } print("Exiting script"."\n");