Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
I've been using this wrong all these years and nobody ever told me
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Jul 31, 2016
1 parent 95a073d commit 18e86d0
Show file tree
Hide file tree
Showing 36 changed files with 170 additions and 171 deletions.
2 changes: 1 addition & 1 deletion src/Rocketeer/Binaries/AbstractBinary.php
Expand Up @@ -141,7 +141,7 @@ public function __call($name, $arguments)
////////////////////////////////////////////////////////////////////

/**
* Returns a command with the SCM's binary.
* Returns a command with the VCS's binary.
*
* @param string|null $command
* @param string|string[] $arguments
Expand Down
Expand Up @@ -10,14 +10,14 @@
*
*/

namespace Rocketeer\Binaries\Scm;
namespace Rocketeer\Binaries\Vcs;

use Rocketeer\Binaries\AbstractBinary;

/**
* The Git implementation of the ScmInterface.
* The Git implementation of the VcsInterface.
*/
class Git extends AbstractBinary implements ScmInterface
class Git extends AbstractBinary implements VcsInterface
{
/**
* The core binary.
Expand All @@ -31,7 +31,7 @@ class Git extends AbstractBinary implements ScmInterface
////////////////////////////////////////////////////////////////////

/**
* Check if the SCM is available.
* Check if the VCS is available.
*
* @return string
*/
Expand Down Expand Up @@ -89,7 +89,7 @@ public function checkout($destination)

// Build flags
$flags = ['--branch' => $repository->branch];
if ($this->config->getContextually('scm.shallow')) {
if ($this->config->getContextually('vcs.shallow')) {
$flags['--depth'] = 1;
}

Expand Down
Expand Up @@ -10,14 +10,14 @@
*
*/

namespace Rocketeer\Binaries\Scm;
namespace Rocketeer\Binaries\Vcs;

use Rocketeer\Binaries\AbstractBinary;

/**
* The Mercury implementation of the ScmInterface.
* The Mercury implementation of the VcsInterface.
*/
class Hg extends AbstractBinary implements ScmInterface
class Hg extends AbstractBinary implements VcsInterface
{
/**
* The core binary.
Expand All @@ -27,7 +27,7 @@ class Hg extends AbstractBinary implements ScmInterface
protected $binary = 'hg';

/**
* Check if the SCM is available.
* Check if the VCS is available.
*
* @return string
*/
Expand Down
Expand Up @@ -10,17 +10,17 @@
*
*/

namespace Rocketeer\Binaries\Scm;
namespace Rocketeer\Binaries\Vcs;

use Rocketeer\Binaries\AbstractBinary;

/**
* The Svn implementation of the ScmInterface.
* The Svn implementation of the VcsInterface.
*
*
* @author Gasillo
*/
class Svn extends AbstractBinary implements ScmInterface
class Svn extends AbstractBinary implements VcsInterface
{
/**
* The core binary.
Expand All @@ -34,7 +34,7 @@ class Svn extends AbstractBinary implements ScmInterface
////////////////////////////////////////////////////////////////////

/**
* Check if the SCM is available.
* Check if the VCS is available.
*
* @return string
*/
Expand Down
Expand Up @@ -10,12 +10,12 @@
*
*/

namespace Rocketeer\Binaries\Scm;
namespace Rocketeer\Binaries\Vcs;

/**
* The interface for all SCM implementations.
* The interface for all VCS implementations.
*/
interface ScmInterface
interface VcsInterface
{
/**
* Get the current binary name.
Expand All @@ -25,7 +25,7 @@ interface ScmInterface
public function getBinary();

/**
* Check if the SCM is available.
* Check if the VCS is available.
*
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Rocketeer/Services/Builders/Builder.php
Expand Up @@ -47,7 +47,7 @@ class Builder implements ModulableInterface, ContainerAwareInterface
protected $lookups = [
'binaries' => [
'Rocketeer\Binaries\PackageManagers\%s',
'Rocketeer\Binaries\Scm\%s',
'Rocketeer\Binaries\Vcs\%s',
'Rocketeer\Binaries\%s',
],
'tasks' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Rocketeer/Services/Config/ConfigurationDefinition.php
Expand Up @@ -18,9 +18,9 @@
use Rocketeer\Services\Config\Definition\PathsDefinition;
use Rocketeer\Services\Config\Definition\PluginsDefinition;
use Rocketeer\Services\Config\Definition\RemoteDefinition;
use Rocketeer\Services\Config\Definition\ScmDefinition;
use Rocketeer\Services\Config\Definition\StagesDefinition;
use Rocketeer\Services\Config\Definition\StrategiesDefinition;
use Rocketeer\Services\Config\Definition\VcsDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

/**
Expand All @@ -36,7 +36,7 @@ class ConfigurationDefinition extends AbstractDefinition
HooksDefinition::class,
PathsDefinition::class,
RemoteDefinition::class,
ScmDefinition::class,
VcsDefinition::class,
StagesDefinition::class,
StrategiesDefinition::class,
PluginsDefinition::class,
Expand Down
Expand Up @@ -170,10 +170,10 @@ protected function getOverridesNodes(NodeBuilder $node)
Per example :
'stages' => [
'staging' => [
'scm' => ['branch' => 'staging'],
'vcs' => ['branch' => 'staging'],
],
'production' => [
'scm' => ['branch' => 'master'],
'vcs' => ['branch' => 'master'],
],
],
EOF
Expand Down
Expand Up @@ -15,14 +15,14 @@
use Symfony\Component\Config\Definition\TreeBuilder\NodeBuilder;

/**
* Configuration schema for the SCM node.
* Configuration schema for the VCS node.
*/
class ScmDefinition extends AbstractDefinition
class VcsDefinition extends AbstractDefinition
{
/**
* @var string
*/
protected $name = 'scm';
protected $name = 'vcs';

/**
* @var string
Expand Down Expand Up @@ -50,22 +50,22 @@ protected function getChildren(NodeBuilder $node)
protected function getCredentialsNodes(NodeBuilder $node)
{
return $node
->enumNode('scm')
->info('The SCM used')
->enumNode('vcs')
->info('The VCS used')
->values(['git', 'svn', 'hg'])
->isRequired()
->defaultValue('git')
->end()
->scalarNode('repository')
->info('The SSH/HTTPS address to your repository')
->example('https://github.com/vendor/website.git')
->defaultValue($this->value('scm.repository'))
->defaultValue($this->value('vcs.repository'))
->end()
->scalarNode('username')
->defaultValue($this->value('scm.username'))
->defaultValue($this->value('vcs.username'))
->end()
->scalarNode('password')
->defaultValue($this->value('scm.password'))
->defaultValue($this->value('vcs.password'))
->end();
}

Expand All @@ -82,7 +82,7 @@ protected function getOptionsNodes(NodeBuilder $node)
->defaultValue('master')
->end()
->scalarNode('shallow')
->info("Whether your SCM should do a \"shallow\" clone of the repository or not - this means a clone with just the latest state of your application (no history).\nIf you're having problems cloning, try setting this to false")
->info("Whether your VCS should do a \"shallow\" clone of the repository or not - this means a clone with just the latest state of your application (no history).\nIf you're having problems cloning, try setting this to false")
->defaultTrue()
->end()
->scalarNode('submodules')
Expand Down
Expand Up @@ -96,7 +96,7 @@ public function publish($format = 'php', $consolidated = false)
public function publishNode($path, $format = 'php', $node = null)
{
if ($this->files->isDirectory($path)) {
foreach (['config', 'hooks', 'paths', 'remote', 'scm', 'stages', 'strategies', 'plugins'] as $file) {
foreach (['config', 'hooks', 'paths', 'remote', 'vcs', 'stages', 'strategies', 'plugins'] as $file) {
$this->publishNode($path.'/'.$file.'.'.$format, $format, $file);
}

Expand Down
Expand Up @@ -50,10 +50,10 @@ public function getCredentials()
*/
public function getRepositoryCredentials()
{
$endpoint = $this->scm->runLocally('currentEndpoint');
$endpoint = $this->vcs->runLocally('currentEndpoint');
$user = $this->bash->runLocally('whoami');

return $this->askQuestions('scm', [
return $this->askQuestions('vcs', [
'repository' => ['Where is your code located?', $endpoint],
'username' => ['What is the username for it?', $user],
'password' => 'And the password?',
Expand Down Expand Up @@ -126,7 +126,7 @@ public function getConnectionCredentials($connectionName)
*/
protected function askQuestions($for, array $questions)
{
$key = $for === 'scm' ? new RepositoryKey() : new ConnectionKey(['server' => 0]);
$key = $for === 'vcs' ? new RepositoryKey() : new ConnectionKey(['server' => 0]);
$credentials = [];
$config = [];

Expand All @@ -148,7 +148,7 @@ protected function askQuestions($for, array $questions)
}

// Set in current configuration
$configKey = $for === 'scm' ? 'scm' : 'connections.'.$for;
$configKey = $for === 'vcs' ? 'vcs' : 'connections.'.$for;
$this->config->set($configKey, $config);

return $credentials;
Expand All @@ -173,7 +173,7 @@ protected function askQuestion($for, $credential, $question)
}

// Get the credential, either through options or prompt
if (($for !== 'scm' || $credential === 'repository') && $option = $this->command->option($credential)) {
if (($for !== 'vcs' || $credential === 'repository') && $option = $this->command->option($credential)) {
return $option;
}

Expand Down
Expand Up @@ -42,7 +42,7 @@ public function getCurrentRepository()
*/
protected function getRepositoryCredentials()
{
$config = (array) $this->config->getContextually('scm');
$config = (array) $this->config->getContextually('vcs');
$credentials = (array) $this->localStorage->get('credentials');

return array_merge($config, $credentials);
Expand Down Expand Up @@ -92,10 +92,10 @@ protected function getRepositoryBranch()
}

// Get branch from config, else compute the fallback
$branch = $this->config->getContextually('scm.branch');
$branch = $this->config->getContextually('vcs.branch');
if (!$branch) {
$fallback = $this->bash->on('local', function () {
return $this->scm->runSilently('currentBranch');
return $this->vcs->runSilently('currentBranch');
});

$fallback = $fallback ?: 'master';
Expand Down
6 changes: 3 additions & 3 deletions src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php
Expand Up @@ -21,9 +21,9 @@
* @method \Rocketeer\Binaries\PackageManagers\Npm npm()
* @method \Rocketeer\Binaries\Php php()
* @method \Rocketeer\Binaries\Phpunit phpunit()
* @method \Rocketeer\Binaries\Scm\Git git()
* @method \Rocketeer\Binaries\Scm\Hg hg()
* @method \Rocketeer\Binaries\Scm\Svn svn()
* @method \Rocketeer\Binaries\Vcs\Git git()
* @method \Rocketeer\Binaries\Vcs\Hg hg()
* @method \Rocketeer\Binaries\Vcs\Svn svn()
*/
class Binaries extends AbstractBashModule
{
Expand Down
14 changes: 7 additions & 7 deletions src/Rocketeer/Strategies/CreateRelease/CloneStrategy.php
Expand Up @@ -15,14 +15,14 @@
use Rocketeer\Strategies\AbstractStrategy;

/**
* Clones a fresh instance of the repository by SCM.
* Clones a fresh instance of the repository by VCS.
*/
class CloneStrategy extends AbstractStrategy implements CreateReleaseStrategyInterface
{
/**
* @var string
*/
protected $description = 'Clones a fresh instance of the repository by SCM';
protected $description = 'Clones a fresh instance of the repository by VCS';

/**
* Deploy a new clean copy of the application.
Expand All @@ -39,7 +39,7 @@ public function deploy($destination = null)

// Executing checkout
$this->explainer->line('Cloning repository in "'.$destination.'"');
$output = $this->scm->run('checkout', $destination);
$output = $this->vcs->run('checkout', $destination);

// Cancel if failed and forget credentials
$success = $this->bash->displayStatusMessage('Unable to clone the repository', $output) !== false;
Expand All @@ -50,9 +50,9 @@ public function deploy($destination = null)
}

// Deploy submodules
if ($this->config->getContextually('scm.submodules') && $this->scm->submodules()) {
if ($this->config->getContextually('vcs.submodules') && $this->vcs->submodules()) {
$this->explainer->line('Initializing submodules if any');
$this->scm->runForCurrentRelease('submodules');
$this->vcs->runForCurrentRelease('submodules');
$success = $this->status();
}

Expand All @@ -69,11 +69,11 @@ public function deploy($destination = null)
public function update($reset = true)
{
$this->explainer->info('Pulling changes');
$tasks = [$this->scm->update()];
$tasks = [$this->vcs->update()];

// Reset if requested
if ($reset) {
array_unshift($tasks, $this->scm->reset());
array_unshift($tasks, $this->vcs->reset());
}

return $this->bash->runForCurrentRelease($tasks);
Expand Down
12 changes: 6 additions & 6 deletions src/Rocketeer/Strategies/StrategiesServiceProvider.php
Expand Up @@ -13,7 +13,7 @@
namespace Rocketeer\Strategies;

use League\Container\ServiceProvider\AbstractServiceProvider;
use Rocketeer\Binaries\Scm\ScmInterface;
use Rocketeer\Binaries\Vcs\VcsInterface;
use Rocketeer\Services\Builders\Builder;
use Rocketeer\Services\Config\ContextualConfiguration;

Expand All @@ -23,7 +23,7 @@ class StrategiesServiceProvider extends AbstractServiceProvider
* @var array
*/
protected $provides = [
ScmInterface::class,
VcsInterface::class,
];

/**
Expand All @@ -34,10 +34,10 @@ public function register()
/** @var ContextualConfiguration $config */
$config = $this->container->get(ContextualConfiguration::class);

// Bind SCM class
$scm = $config->getContextually('scm.scm');
$this->container->add(ScmInterface::class, function () use ($scm) {
return $this->container->get(Builder::class)->buildBinary($scm);
// Bind VCS class
$vcs = $config->getContextually('vcs.vcs');
$this->container->add(VcsInterface::class, function () use ($vcs) {
return $this->container->get(Builder::class)->buildBinary($vcs);
});
}
}

0 comments on commit 18e86d0

Please sign in to comment.