-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.php
33 lines (29 loc) · 809 Bytes
/
git.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
function git_pull():bool {
$output = [];
if (exec("git pull" , $output , $exitcode) === FALSE) {
echo ERROR . "failed to execute git pull\n";
return FALSE;
}
echo implode("\n" , $output) . "\n";
if ($exitcode !== 0) {
echo ERROR . "git pull terminated with exit code " . $exitcode . "\n";
return FALSE;
}
return TRUE;
}
function git_checkout(string $branch):bool {
$output = [];
if (exec("git checkout " . $branch , $output , $exitcode) === FALSE) {
echo ERROR . "failed to execute git checkout";
return FALSE;
}
echo implode("\n" , $output) . "\n";
if ($exitcode !== 0) {
echo ERROR . "git checkout terminated with exit code " . $exitcode . "\n";
return FALSE;
}
return TRUE;
}
?>