Skip to content

Commit a189c4d

Browse files
committed
Make repository refresh much faster
1 parent b42f1a9 commit a189c4d

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

.maintenance/clone-all-repositories.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@
1111
'wp-cli-dev',
1212
);
1313

14-
$request = 'https://api.github.com/orgs/wp-cli/repos?per_page=100';
15-
$response = shell_exec( "curl -s {$request}" );
16-
$repositories = json_decode( $response );
17-
$pwd = getcwd();
14+
$request = 'https://api.github.com/orgs/wp-cli/repos?per_page=100';
15+
$response = shell_exec( "curl -s {$request}" );
16+
$repositories = json_decode( $response );
17+
$pwd = getcwd();
18+
$update_folders = [];
1819

1920
foreach ( $repositories as $repository ) {
2021
if ( in_array( $repository->name, $skip_list, true ) ) {
2122
continue;
2223
}
2324

2425
if ( ! is_dir( $repository->name ) ) {
25-
printf( "Fetching \033[32mwp-cli/{$repository->name}\033[0m:\n" );
26+
printf( "Fetching \033[32mwp-cli/{$repository->name}\033[0m...\n" );
2627
system( "git clone {$repository->clone_url}" );
27-
} else {
28-
printf( "Updating \033[33mwp-cli/{$repository->name}\033[0m:\n" );
29-
system( "cd {$repository->name} && git checkout master && git pull; cd {$pwd}" );
3028
}
29+
30+
$update_folders[] = $repository->name;
3131
}
32+
33+
$updates = implode( ' ', $update_folders );
34+
system( "echo $updates | xargs -n1 -P8 -I% php .maintenance/refresh-repository.php %" );
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
if ( ! isset ( $argv[1] ) || ! is_dir( $argv[1] ) ) {
4+
exit( "Usage: php refresh-repository.php <repository-folder>\n" );
5+
}
6+
7+
$repository = $argv[1];
8+
$path = realpath( getcwd() . "/{$repository}" );
9+
10+
printf( "--- Refreshing repository \033[32m{$repository}\033[0m ---\n" );
11+
12+
printf( "Switching to latest \033[33mmaster\033[0m branch...\n" );
13+
system( "git --git-dir={$path}/.git --work-tree={$path} checkout master" );
14+
15+
printf( "Pulling latest changes...\n" );
16+
system( "git --git-dir={$path}/.git --work-tree={$path} pull" );

.maintenance/symlink-vendor-folders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
foreach ( $repositories as $repository ) {
88
if ( ! is_dir( "{$repository}/vendor" ) && is_file( "{$repository}/composer.json" ) ) {
9-
printf( "Symlinking \033[33mwp-cli/{$repository}/vendor\033[0m folder:\n" );
9+
printf( "Symlinking \033[33mwp-cli/{$repository}/vendor\033[0m folder...\n" );
1010

1111
// We don't symlink the vendor folder directly, but rather create a real
1212
// vendor folder and symlink each of the subfolders instead.

.readme-partials/INSTALLATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ This will:
1010

1111
1. Clone all relevant packages from the `wp-cli` GitHub organization into the `wp-cli-dev` folder, and
1212
2. Install all Composer dependencies for a complete `wp-cli-bundle` setup, while symlinking all of the previously cloned packages into the Composer `vendor` folder.
13+
3. Symlink all folder in `vendor` into corresponding `vendor` folders in each repository, thus making the centralized functionality based on Composer available in each repository subfolder.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This will:
2323

2424
1. Clone all relevant packages from the `wp-cli` GitHub organization into the `wp-cli-dev` folder, and
2525
2. Install all Composer dependencies for a complete `wp-cli-bundle` setup, while symlinking all of the previously cloned packages into the Composer `vendor` folder.
26+
3. Symlink all folder in `vendor` into corresponding `vendor` folders in each repository, thus making the centralized functionality based on Composer available in each repository subfolder.
2627

2728
## Development
2829

0 commit comments

Comments
 (0)