-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathupload-this-to-server
More file actions
executable file
·53 lines (42 loc) · 1.44 KB
/
upload-this-to-server
File metadata and controls
executable file
·53 lines (42 loc) · 1.44 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env php
<?php
/*
* Copyright 2013 Daniel James <daniel@calamity.org.uk>.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
require_once(__DIR__.'/vendor/autoload.php');
use BoostTasks\Process;
use BoostTasks\Settings;
use BoostTasks\RepoBase;
use BoostTasks\Log;
// use RuntimeException;
Settings::init();
try {
$dst = Settings::dataPath().'/upload';
if (is_dir($dst)) {
Process::run("rm -r {$dst}");
}
mkdir($dst);
$repo = new RepoBase(__DIR__);
$hash = trim($repo->commandWithOutput("rev-parse HEAD"));
$repo->command("archive {$hash} | tar -x -C {$dst}");
file_put_contents("{$dst}/commit_hash.txt", $hash);
#Process::run("rm -r {$dst}/nbproject");
Process::run("rm {$dst}/upload-this-to-server");
Process::run("rsync --exclude var --exclude vendor -azv --delete-after {$dst}/ dnljms@boost.org:boost-tasks/");
// Record the upload.
$repo->command("fetch -p");
$tree_hash = trim($repo->commandWithOutput("rev-parse {$hash}^{tree}"));
$commit_hash = trim($repo->commandWithOutput("commit-tree -m Upload -p origin/upload -p {$hash} {$tree_hash}"));
$repo->command("push origin {$commit_hash}:upload");
}
catch (RuntimeException $e) {
Log::error("Runtime exception: {$e}");
exit(1);
}
// Return an error code if an error was logged.
if (Log::$error) {
exit(1);
}