xaizek / fragile (License: AGPLv3+) (since 2018-12-07)
Simple lightweight CI, attempting to be somewhat Unix-like in its philosophy.
Commit 73dc60b82eee66e1e165410340b86f939185c767

Move delTree() into a helper Utils class
Author: xaizek
Author date (UTC): 2018-02-11 12:14
Committer name: xaizek
Committer date (UTC): 2018-02-11 14:06
Parent(s): 9ce6d6bdb442e0927bef3bef50c8d541e07b9f59
Signing key: 99DC5E4DB05F6BE2
Tree: 2a3d3d877068bbed7554ddee6538bc6c3b3cf6d3
File Lines added Lines deleted
classes/Utils.php 27 3
daemon.php 2 17
File classes/Utils.php copied from file footer.php (similarity 51%) (mode: 100644) (index e91aa93..624b77c)
1 1 <?php <?php
2 // Copyright (C) 2015 xaizek <xaizek@posteo.net>
2 // Copyright (C) 2018 xaizek <xaizek@posteo.net>
3 3 // //
4 4 // fragile is free software: you can redistribute it and/or modify it under the // fragile is free software: you can redistribute it and/or modify it under the
5 5 // terms of the GNU Affero General Public License as published by the Free // terms of the GNU Affero General Public License as published by the Free
 
13 13 // You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
14 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
15 15
16 print "<footer><a href='" . CI_URL . "'>fragile v0.5</a></footer>\n"
17 . "</body></html>";
16 /**
17 * @brief Helper functions.
18 */
19 class Utils
20 {
21 /**
22 * @brief Removes subtree.
23 *
24 * @param dir Directory path to remove.
25 *
26 * @returns Result of rmdir().
27 */
28 public static function delTree($dir)
29 {
30 $files = array_diff(scandir($dir), ['.', '..']);
31 foreach ($files as $file) {
32 if (is_dir("$dir/$file")) {
33 Utils::delTree("$dir/$file");
34 } else {
35 unlink("$dir/$file");
36 }
37 }
38 return rmdir($dir);
39 }
40
41 }
18 42
19 43 ?> ?>
File daemon.php changed (mode: 100644) (index 623ace7..27c3306)
15 15
16 16 require_once __DIR__ . '/classes/Builds.php'; require_once __DIR__ . '/classes/Builds.php';
17 17 require_once __DIR__ . '/classes/Buildset.php'; require_once __DIR__ . '/classes/Buildset.php';
18 require_once __DIR__ . '/classes/Utils.php';
18 19 require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
19 20
20 21 // TODO: maybe mark all "running" builds as failed // TODO: maybe mark all "running" builds as failed
 
... ... function prepareRepository()
39 40
40 41 system(__DIR__ . "/vcs/clone '" . REPO_URL . "'", $retval); system(__DIR__ . "/vcs/clone '" . REPO_URL . "'", $retval);
41 42 if ($retval != 0) { if ($retval != 0) {
42 delTree(REPO_PATH);
43 Utils::delTree(REPO_PATH);
43 44 die("Failed to clone repository\n"); die("Failed to clone repository\n");
44 45 } }
45 46 } }
46 47
47 /**
48 * @brief Removes subtree.
49 *
50 * @param dir Directory path to remove.
51 *
52 * @returns Result of rmdir().
53 */
54 function delTree($dir)
55 {
56 $files = array_diff(scandir($dir), ['.', '..']);
57 foreach ($files as $file) {
58 (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
59 }
60 return rmdir($dir);
61 }
62
63 48 /** /**
64 49 * @brief Performs infinite loop of running builds. * @brief Performs infinite loop of running builds.
65 50 */ */
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/fragile

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/fragile

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master