![Stable Build Status](http://img.shields.io/travis/contao-community-alliance/vcs-synchronizer/master.svg?style=flat-square&label=stable build) ![Upstream Build Status](http://img.shields.io/travis/contao-community-alliance/vcs-synchronizer/develop.svg?style=flat-square&label=dev build)
This repository contains multiple synchronizers to synchronize multiple VCS repositories (of the same type).
Symmetric synchronisation means that each repository is compared and synchronized against each other. If a conflict is detected - two remotes have divergent branches - no repository of the concerned branch is synchronized.
Asymmetric synchronisation means that one - the primary - repository is compared and synchronized against all the others repositories. If a conflict is detected - one remote branch is ahead of the primary - the branch in the concerned repository is not synchronized.
The synchronizers work on a local working repository. But they won't create them for you! This let you keep control of what happened.
Here is an example, how you could create the local working repository.
use ContaoCommunityAlliance\BuildSystem\Repository\GitRepository;
$path = tempnam(sys_get_temp_dir());
unlink($path);
mkdir($path);
$repository = new GitRepository($path);
$repository->init()->execute();
$repository->remote()->add('github', 'git@github.com:contao-community-alliance/vcs-synchronizer.git')->execute();
$repository->remote()->add('bitbucket', 'git@bitbucket.org:contao-community-alliance/vcs-synchronizer.git')->execute();
CLI usage
./bin/git-branches-symmetric-sync -b github -b bitbucket /path/to/repository
PHP usage
use ContaoCommunityAlliance\BuildSystem\VcsSync\Synchronizer\GitSymmetricBranchSynchronizer;
$synchronizer = new GitSymmetricBranchSynchronizer(
// the working repository
$repository,
// the remotes to synchronize
['github', 'bitbucket']
);
$synchronizer->setLogger($logger);
$synchronizer->sync();
CLI usage
./bin/git-branches-asymmetric-sync -b github -b bitbucket -p github /path/to/repository
PHP usage
use ContaoCommunityAlliance\BuildSystem\VcsSync\Synchronizer\GitAsymmetricBranchSynchronizer;
$synchronizer = new GitAsymmetricBranchSynchronizer(
// the working repository
$repository,
// the remotes to synchronize
['github', 'bitbucket'],
// the primary remote
'github'
);
$synchronizer->setLogger($logger);
$synchronizer->sync();
CLI usage
./bin/git-tags-asymmetric-sync -b github -b bitbucket -p github /path/to/repository
PHP usage
use ContaoCommunityAlliance\BuildSystem\VcsSync\Synchronizer\GitAsymmetricTagSynchronizer;
$synchronizer = new GitAsymmetricTagSynchronizer(
// the working repository
$repository,
// the remotes to synchronize
['github', 'bitbucket'],
// the primary remote
'github'
);
$synchronizer->setLogger($logger);
$synchronizer->sync();