@@ 26-48 (lines=23) @@ | ||
23 | /** |
|
24 | * {@inheritDoc} |
|
25 | */ |
|
26 | public function install(InstalledRepositoryInterface $repo, PackageInterface $package) |
|
27 | { |
|
28 | parent::install($repo, $package); |
|
29 | ||
30 | $gitRootPath = realpath($this->getGitRootPath()); |
|
31 | if (!is_dir($gitRootPath) || !file_exists($gitRootPath)) { |
|
32 | $this->io->writeError(sprintf(' <warning>Skipped installation of %s: Not a git repository found on "git-root" path %s</warning>', $package->getName(), $gitRootPath)); |
|
33 | return; |
|
34 | } |
|
35 | ||
36 | $originPath = $this->getInstallPath($package); |
|
37 | $targetPath = $this->getGitHooksInstallPath(); |
|
38 | ||
39 | if ($this->io->isVerbose()) { |
|
40 | $this->io->write(sprintf(' Installing git hooks from %s into %s', $originPath, $targetPath)); |
|
41 | } |
|
42 | ||
43 | // throws exception if one of both paths doesn't exists or couldn't be created |
|
44 | $this->filesystem->ensureDirectoryExists($originPath); |
|
45 | $this->filesystem->ensureDirectoryExists($targetPath); |
|
46 | ||
47 | $this->copyGitHooks($originPath, $targetPath); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * {@inheritDoc} |
|
@@ 53-75 (lines=23) @@ | ||
50 | /** |
|
51 | * {@inheritDoc} |
|
52 | */ |
|
53 | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) |
|
54 | { |
|
55 | parent::update($repo, $initial, $target); |
|
56 | ||
57 | $gitRootPath = realpath($this->getGitRootPath()); |
|
58 | if (!is_dir($gitRootPath)) { |
|
59 | $this->io->writeError(sprintf(' <warning>Skipped update of %s: Not a git repository found on "git-root" path %s</warning>', $target->getName(), $gitRootPath)); |
|
60 | return; |
|
61 | } |
|
62 | ||
63 | $originPath = $this->getInstallPath($initial); |
|
64 | $targetPath = $this->getGitHooksInstallPath(); |
|
65 | ||
66 | if ($this->io->isVerbose()) { |
|
67 | $this->io->write(sprintf(' Updating git hooks from %s into %s', $originPath, $targetPath)); |
|
68 | } |
|
69 | ||
70 | // throws exception if one of both paths doesn't exists or couldn't be created |
|
71 | $this->filesystem->ensureDirectoryExists($originPath); |
|
72 | $this->filesystem->ensureDirectoryExists($targetPath); |
|
73 | ||
74 | $this->copyGitHooks($originPath, $targetPath, true); |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * {@inheritDoc} |