Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a52fefe

Browse files
committed
Add EXCLUDE_FILES, RSYNC_FLAGS options
EXCLUDE_FILES - specify files should not be copied to TARGET_DIR, default: .git RSYNC_FLAGS - specify flags for rsync commands, default: -rltgoDzvO If any of these options is not defined, default value will be used instead (the same as hardcoded before this commit)
1 parent 4497a46 commit a52fefe

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ If you are using a public repository you can start here.
9898
* __LOG_FILE__: (optional) the full path of file to log all script output
9999
* __EMAIL_NOTIFICATIONS__: (optional) email address to which a copy of the script output will be sent
100100
* __TIME_LIMIT__: maximum time allowed for each command, in seconds. 60 should be fine unless your deployments are massive. Adjust if necessary.
101+
* __EXCLUDE_FILES__: (optional) array of files or filename patterns which won't be copied to `TARGET_DIR` . By default it's `.git`.
102+
* __RSYNC_FLAGS__: (optional) override rsync flags. By default, it's `-rltgoDzvO` .
101103

102104
NOTE: do not include/track the files `deploy-config.php` and `VERSION` in your repository.
103105

‎deploy-config.orig.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,21 @@
6464

6565
/* TIME_LIMIT: Time limit for each command */
6666
define('TIME_LIMIT', 60);
67+
68+
/* EXCLUDE_FILES:
69+
* Array of files excluded from rsync (they will appear in GIT_DIR, but not in TARGET_DIR)
70+
* By default, only .git directory is excluded.
71+
* It's recommended to leave '.git' excluded and add something more if needed.
72+
* Example: define('EXCLUDE_FILES', serialize(array('.git', '.gitignore', '*.less', '*.scss')));
73+
*
74+
*/
75+
define('EXCLUDE_FILES', serialize(array('.git')));
76+
77+
/* RSYNC_FLAGS:
78+
* Custom flags to run rsync with
79+
* Default: '-rltgoDzvO'
80+
* Do not change them if not necessary
81+
* Example: '-rltDzvO' (don't changes owner:group of copied files,
82+
* useful for vhosts than require separate group for document_root to be accessible by webserver)
83+
*/
84+
define('RSYNC_FLAGS', '-rltgoDzvO');

‎deploy.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ function endScript() {
8181
if (!defined('GIT_DIR') || GIT_DIR === '') $err[] = 'Git directory is not configured';
8282
if (!defined('TARGET_DIR') || TARGET_DIR === '') $err[] = 'Target directory is not configured';
8383
if (!defined('TIME_LIMIT')) define('TIME_LIMIT', 60);
84+
if (!defined('EXCLUDE_FILES')) define('EXCLUDE_FILES', serialize(array('.git')));
85+
if (!defined('RSYNC_FLAGS')) define('RSYNC_FLAGS', '-rltgoDzvO');
8486

8587
// If there is a configuration error
8688
if (count($err)) {
@@ -413,11 +415,17 @@ function cmd($command, $print = true) {
413415
);
414416
echo "\nNOTE: repository files that have been modfied or removed in target directory will be resynced with repository even if not listed in commits\n";
415417

416-
// rsync all added and modified files (no deletes, exclude .git directory)
418+
// Build exclusion list
419+
$exclude = unserialize(EXCLUDE_FILES);
420+
array_unshift($exclude, '');
421+
422+
// rsync all added and modified files (by default: no deletes, exclude .git directory)
417423
cmd(sprintf(
418-
'rsync -rltgoDzvO %s %s --exclude=.git'
424+
'rsync %s %s %s %s'
425+
, RSYNC_FLAGS
419426
, GIT_DIR
420427
, TARGET_DIR
428+
, implode(' --exclude=', $exclude)
421429
));
422430
echo "\nDeleting files removed from repository\n";
423431

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /