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