Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $currentUser = get_current_user();
     $privateKey = php_uname('s') == 'Darwin' ? realpath("/Users/{$currentUser}/.ssh/id_rsa") : realpath("/home/{$currentUser}/.ssh/id_rsa");
     $blog = base_path('resources/blog/');
     $git = new GitWrapper();
     $git->setPrivateKey($privateKey);
     if (!file_exists($blog)) {
         $git->cloneRepository(config('blog.repository'), $blog);
     }
     $git->git('pull origin master', $blog);
 }
 public function deleteConfig(ConfigCrudEvent $event)
 {
     $config = \Drupal::config('git_config.config');
     $private_key = $config->get('private_key');
     $git_url = $config->get('git_url');
     $active_dir = \Drupal::config('config_files.config')->get('directory');
     if ($active_dir && !empty($private_key) && !empty($git_url)) {
         $wrapper = new GitWrapper();
         $wrapper->setPrivateKey($config->get('private_key'));
         $git = $wrapper->workingCopy($active_dir);
         $object = $event->getConfig();
         $file_name = $object->getName() . '.yml';
         try {
             $user = \Drupal::currentUser();
             $name = $user->getAccount()->getUsername();
             $git->rm($file_name)->commit(t('Removed by @name', array('@name' => $name)))->push();
         } catch (GitException $e) {
             drupal_set_message($e->getMessage(), 'warning');
         }
     }
 }
Exemplo n.º 3
0
 private function getGitWrapper()
 {
     $wrapper = new GitWrapper();
     $wrapper->setPrivateKey($this->privateKeyPath);
     return $wrapper;
 }