@@ -73,14 +73,14 @@ protected function execute(InputInterface $input, OutputInterface $output) {
7373 $ this ->io ->comment (sprintf ('Checking out %s (%s) on %s ' ,
7474 $ this ->siteName ,
7575 $ this ->ref ,
76- $ this ->destination
76+ $ this ->repo [ ' directory ' ]
7777 ));
7878
7979 switch ($ this ->repo ['type ' ]) {
8080 case 'git ' :
8181 // Check if repo exists and has any changes.
82- if ($ this ->fileExists ($ this ->destination ) &&
83- $ this ->fileExists ($ this ->destination . '. ' . $ this ->repo ['type ' ])
82+ if ($ this ->fileExists ($ this ->repo [ ' directory ' ] ) &&
83+ $ this ->fileExists ($ this ->repo [ ' directory ' ] . '. ' . $ this ->repo ['type ' ])
8484 ) {
8585 if ($ input ->hasOption ('force ' ) &&
8686 !$ input ->getOption ('force ' )
@@ -111,10 +111,13 @@ protected function execute(InputInterface $input, OutputInterface $output) {
111111 * @throws CommandException
112112 *
113113 * @return string Repo url
114+ *
115+ * @todo validate for all command that use repo config.
114116 */
115117 protected function validateRepo () {
116118 if (isset ($ this ->config ['repo ' ])) {
117119 $ this ->repo = $ this ->config ['repo ' ];
120+ $ this ->repo ['directory ' ] = rtrim ($ this ->repo ['directory ' ], '/ ' ) . '/ ' ;
118121 }
119122 else {
120123 throw new CommandException ('Repo not found in sites.yml ' );
@@ -133,7 +136,7 @@ protected function validateRepo() {
133136 protected function gitDiff () {
134137 $ command = sprintf (
135138 'cd %s && git diff-files --name-status -r --ignore-submodules ' ,
136- $ this ->shellPath ($ this ->destination )
139+ $ this ->shellPath ($ this ->repo [ ' directory ' ] )
137140 );
138141
139142 $ shellProcess = $ this ->getShellProcess ();
@@ -143,7 +146,7 @@ protected function gitDiff() {
143146 $ message = sprintf ('You have uncommitted changes on %s ' . PHP_EOL .
144147 'Please commit or revert your changes before checking out the site. ' . PHP_EOL .
145148 'If you want to wipe your local changes use --force. ' ,
146- $ this ->destination
149+ $ this ->repo [ ' directory ' ]
147150 );
148151 throw new CommandException ($ message );
149152 }
@@ -165,14 +168,14 @@ protected function gitDiff() {
165168 protected function gitClone () {
166169 $ command = sprintf ('git clone %s %s ' ,
167170 $ this ->repo ['url ' ],
168- $ this ->shellPath ($ this ->destination )
171+ $ this ->shellPath ($ this ->repo [ ' directory ' ] )
169172 );
170173 $ this ->io ->commentBlock ($ command );
171174
172175 $ shellProcess = $ this ->getShellProcess ();
173176
174177 if ($ shellProcess ->exec ($ command , TRUE )) {
175- $ this ->io ->success (sprintf ('Repo cloned on %s ' , $ this ->destination ));
178+ $ this ->io ->success (sprintf ('Repo cloned on %s ' , $ this ->repo [ ' directory ' ] ));
176179 }
177180 else {
178181 throw new CommandException ($ shellProcess ->getOutput ());
@@ -192,15 +195,14 @@ protected function gitClone() {
192195 * @throws CommandException
193196 */
194197 protected function gitCheckout () {
195- $ command = sprintf (
196- 'cd %s && ' .
197- 'git fetch --all && ' .
198- 'chmod 777 web/sites/default && ' .
199- 'chmod 777 web/sites/default/settings.php && ' .
200- 'git checkout %s --force ' ,
201- $ this ->shellPath ($ this ->destination ),
202- $ this ->ref
203- );
198+ $ commands = [
199+ sprintf ('cd %s ' , $ this ->shellPath ($ this ->repo ['directory ' ])),
200+ 'git fetch --all ' ,
201+ sprintf ('chmod 777 %s/sites/default ' , $ this ->drupal_directory ),
202+ sprintf ('chmod 777 %s/sites/default/settings.php ' , $ this ->drupal_directory ),
203+ sprintf ('git checkout %s --force ' , $ this ->ref ),
204+ ];
205+ $ command = implode (' && ' , $ commands );
204206
205207 $ shellProcess = $ this ->getShellProcess ();
206208
@@ -221,10 +223,10 @@ protected function gitCheckout() {
221223 * @return mixed
222224 */
223225 protected function getCurrentRef () {
224- if ($ this ->fileExists ($ this ->destination )) {
226+ if ($ this ->fileExists ($ this ->repo [ ' directory ' ] )) {
225227 // Get branch from site directory.
226228 $ command = sprintf ('cd %s && git branch ' ,
227- $ this ->shellPath ($ this ->destination )
229+ $ this ->shellPath ($ this ->repo [ ' directory ' ] )
228230 );
229231
230232 $ shellProcess = $ this ->getShellProcess ()->printOutput (FALSE );
0 commit comments