-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git checkout and composer install commands.
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...g/src/Plugins/Command/ComposerInstall.php → ...ng/src/Plugin/Command/ComposerInstall.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Drupal/Modules/site_hosting/src/Plugin/Command/GitCheckout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Drupal\site_hosting\Plugin\Command; | ||
|
||
use Drupal\commands\CommandPluginBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\user\Entity\User; | ||
|
||
/** | ||
* Clones and checks out code. | ||
* | ||
* @Command( | ||
* id = "git_checkout", | ||
* label = @Translation("Git Checkout"), | ||
* description = @Translation("Clone a git repository and checkout the desired git reference."), | ||
* command = { | ||
* "git clone [git_remote] [git_root]", | ||
* "cd [git_root]", | ||
* "git fetch", | ||
* "git checkout [git_reference]", | ||
* } | ||
* ) | ||
*/ | ||
class GitCheckout extends CommandPluginBase { | ||
|
||
// public function command($params = []) { | ||
// $command = <<<CMD | ||
//git clone $git_remote $git_root | ||
//cd $git_root | ||
//git fetch | ||
//git checkout $git_reference | ||
//CMD; | ||
// return $command; | ||
// | ||
// } | ||
|
||
/** | ||
* Show a form on the "Run command" form. | ||
* @return void | ||
*/ | ||
public function form($form, FormStateInterface $form_state) { | ||
$form['parameters']['git_remote'] = [ | ||
'#type' => 'textfield', | ||
'#title' => t('Git Remote'), | ||
'#description'=> t('The remote URL of the repository to clone.'), | ||
]; | ||
$form['parameters']['git_root'] = [ | ||
'#type' => 'textfield', | ||
'#title' => t('Git Root'), | ||
'#description'=> t('The absolute path to the root of the repository.'), | ||
]; | ||
$form['parameters']['git_reference'] = [ | ||
'#type' => 'textfield', | ||
'#title' => t('Git Reference'), | ||
'#description'=> t('The git reference to checkout.'), | ||
]; | ||
|
||
// @TODO: Reset working_directory to detected composer root. | ||
return $form; | ||
} | ||
} |
Empty file.