Example #1
0
 /**
  * @param $repo
  * @return mixed
  */
 protected function getCommit(Repo $repo)
 {
     $input = $this->option('commit');
     if ($commit = $input) {
         return $repo->git()->getCommit($commit);
     }
     return $repo->git()->getHeadCommit();
 }
Example #2
0
 public function handle()
 {
     $path = $this->repo->repoPath();
     if (!$this->fs->isDirectory($path) && !$this->fs->makeDirectory($path, 0755, true)) {
         throw new \RuntimeException(sprintf("Cannot create repo dir %s", $path));
     }
     Admin::cloneTo($path, $this->repo->url, true, config('git.options'));
     $this->repo->git()->run('config', ['remote.origin.fetch', 'refs/heads/*:refs/heads/*']);
 }
Example #3
0
 /**
  * Run pull or clone if repo is not initialized yet
  * @param Pusher $pusher
  */
 public function handle(Pusher $pusher)
 {
     if (is_null($this->repo->git())) {
         $this->dispatch(new CloneRepoJob($this->repo));
         return;
     }
     $this->repo->git()->run('fetch', ['origin', '+refs/heads/*:refs/heads/*', '--prune']);
     $this->checkCommitsForDeployTags();
     $pusher->trigger(['pulls'], 'repo-' . $this->repo->id, []);
 }
Example #4
0
 /**
  * @param Repo $repo
  * @param string $commit
  * @return DogproConfig|JsonResponse
  */
 public function config(Repo $repo, $commit)
 {
     $commit = $repo->git()->getCommit($commit);
     if (!$commit) {
         abort(404);
     }
     try {
         $tree = $commit->getTree()->getEntry(DogproConfig::FILENAME);
         if ($tree instanceof Blob) {
             return new DogproConfig($tree->getContent());
         }
     } catch (InvalidArgumentException $e) {
         return response()->json(['error' => 'Configuration file not found!'], 422);
     } catch (ParseException $e) {
         return response()->json(['error' => 'Could not parse configuration file: ' . $e->getMessage()], 422);
     }
     return new JsonResponse(new \stdClass());
 }