-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.php
68 lines (62 loc) · 1.72 KB
/
sync.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace VMSync;
/**
* Syncs local git changes to remote (S)FTP site bby finding all files changed
* since the last commit SHA recorded on server
*/
class Sync
{
/** current working directory */
public $cwd;
/** location of commit file */
public $commit_file;
/** files to back up */
public $backups;
/** files to ignore */
public $ignoredFiles;
/** folders to ignore */
public $ignoredFolders;
/** If true, progress of files being synced will be printed during operations */
public $showProgress;
/**
* Construct a new object to sync all changed files from current repository
* @param Site[] $sites Array of sites to sync to
* @param boolean $showProgress TRUE if progress bar is to be displayed
* @throws InvalidArgumentException if the provided argument is not of type 'array'.
*/
public function __construct($sites, $showProgress = false)
{
if (!is_array($sites)) {
throw new InvalidArgumentException("An array of Sites must be provided");
}
$this->ignoredFiles = [
".gitignore",
".travis.yml",
".gitlab-ci.yml",
"composer.json",
"composer.lock",
"README.md",
"VERSION.md",
];
$this->ignoredFolders = [
"vendor",
"\.git"
];
}
/**
* Adds a file to exclude during sync
* @param string $file File path
*/
public function ignoreFile($file)
{
$this->ignoredFiles[] = $file;
}
/**
* Adds a folder to exclude during sync
* @param string $folder Folder path
*/
public function ignoreFolder($folder)
{
$this->ignoredFolders[] = $folder;
}
}