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 81a4490

Browse files
committed
Add cleanup work tree option
Cleans git work tree after running custom commands. Does not clean TARGET_DIR
1 parent 2a3d15e commit 81a4490

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ If you are using a public repository you can start here.
102102
* __RSYNC_FLAGS__: (optional) override rsync flags. By default, it's `-rltgoDzvO` .
103103
* __COMMANDS_BEFORE_RSYNC__: (optional) array of commands executed between pulling remote repository and copying files to target directory. These commands are executed under `GIT_DIR` directory.
104104
* __COMMANDS_AFTER_RSYNC__: (optional) array of commands executed after copying files to target directory. These commands are executed under `TARGET_DIR` directory.
105+
* __CLEANUP_WORK_TREE__: (optional) set to `true` if you want to clean `GIT_DIR` from intermediate files created by custom commands and rebuild project from scratch every time. Does not affect `TARGET_DIR` at all.
105106

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

‎deploy-config.orig.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,11 @@
9898
* Example: define('COMMANDS_AFTER_RSYNC', serialize(array('rm cache/*.php -f')));
9999
*/
100100
define('COMMANDS_AFTER_RSYNC', serialize(array()));
101+
102+
/* CLEANUP_WORK_TREE:
103+
* Clean GIT_DIR from leftovers after custom commands
104+
* Set to true if you wish to clean up GIT_DIR after running all custom commands
105+
* Useful if your custom commands create intermediate files you want not to keep between deployments
106+
* However, intermediate files would not be cleaned up from TARGET_DIR
107+
*/
108+
define('CLEANUP_WORK_TREE', false);

‎deploy.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,16 @@ function cmd($command, $print = true, $dir = GIT_DIR) {
448448
}
449449
}
450450

451+
// Cleanup work tree from build results, etc
452+
if(defined('CLEANUP_WORK_TREE') && !empty(CLEANUP_WORK_TREE)){
453+
echo "\nCleanup work tree\n";
454+
cmd(sprintf(
455+
'git --git-dir="%s.git" --work-tree="%s" clean -dfx'
456+
, GIT_DIR
457+
, GIT_DIR
458+
));
459+
}
460+
451461
// Update version file to current commit
452462
echo "\nUpdate target directory version file to commit $checkout\n";
453463
cmd(sprintf(

0 commit comments

Comments
(0)

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