-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathupgrade-cli
More file actions
executable file
·32 lines (24 loc) · 812 Bytes
/
upgrade-cli
File metadata and controls
executable file
·32 lines (24 loc) · 812 Bytes
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
#!/usr/bin/env php
<?php
if ($argc < 3) {
exit('Usage: ./upgrade-cli <tag1> <tag2>' . PHP_EOL);
}
[, $commit1, $commit2] = $argv;
$baseDir = __DIR__;
$directory = $baseDir . '/upgrades';
if (! file_exists($directory)) {
mkdir($directory, 0755);
}
exec('git pull');
$command = shell_exec('git diff ' . $commit1 . ' ' . $commit2 . ' --name-only');
$files = explode(PHP_EOL, $command);
foreach ($files as $file) {
if ($file && file_exists($baseDir . '/' . $file)) {
if (! file_exists($directory . '/' . dirname($file))) {
mkdir($directory . '/' . dirname($file), 0755, true);
}
echo 'copy: ' . $baseDir . '/' . $file . PHP_EOL;
copy($baseDir . '/' . $file, $directory . '/' . dirname($file) . '/' . basename($file));
}
}
echo 'success' . PHP_EOL;