@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace Kendrick\SymfonyDebugToolbarGit\DataCollector; |
| 4 | 4 | |
| 5 | 5 | use Kendrick\SymfonyDebugToolbarGit\Git\Git; |
| 6 | -use Kendrick\SymfonyDebugToolbarGit\Git\GitLastCommit; |
|
| 7 | 6 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 8 | 7 | use Symfony\Component\HttpKernel\DataCollector\DataCollector; |
| 9 | 8 | use Symfony\Component\HttpFoundation\Request; |
@@ -16,227 +16,227 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class GitDataCollector extends DataCollector |
| 18 | 18 | { |
| 19 | - private $gitService; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @param $repositoryCommitUrl |
|
| 23 | - */ |
|
| 24 | - public function __construct(ContainerInterface $container) |
|
| 25 | - { |
|
| 26 | - $this->gitService = $container->get('debug.toolbar.git'); |
|
| 27 | - $this->data['repositoryCommitUrl'] = $container->getParameter( |
|
| 28 | - 'symfony_debug_toolbar_git.repository_commit_url' |
|
| 29 | - ); |
|
| 30 | - $this->data['gitData'] = true; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Collect Git data for DebugBar (branch,commit,author,email,merge,date,message) |
|
| 35 | - * @param Request $request |
|
| 36 | - * @param Response $response |
|
| 37 | - * @param \Exception $exception |
|
| 38 | - */ |
|
| 39 | - public function collect(Request $request, Response $response, \Exception $exception = null) |
|
| 40 | - { |
|
| 41 | - |
|
| 42 | - if (!file_exists($this->gitService->getGitDir())) { |
|
| 43 | - $this->data['gitData'] = false; |
|
| 44 | - return; |
|
| 45 | - } |
|
| 46 | - $this->data['gitDir'] = $this->gitService->getGitDir(); |
|
| 47 | - $this->data['branch'] = $this->gitService->shellExec(GitCommand::GIT_CURRENT_BRANCH); |
|
| 48 | - $this->data['commit'] = $this->gitService->shellExec(GitCommand::GIT_HASH_LAST_COMMIT); |
|
| 49 | - $this->data['author'] = $this->gitService->shellExec(GitCommand::GIT_AUTHOR_LAST_COMMIT); |
|
| 50 | - $this->data['email'] = $this->gitService->shellExec(GitCommand::GIT_EMAIL_LAST_COMMIT); |
|
| 51 | - $this->data['message'] = $this->gitService->shellExec(GitCommand::GIT_MESSAGE_LAST_COMMIT); |
|
| 52 | - $this->data['merge'] = $this->gitService->shellExec( |
|
| 53 | - GitCommand::GIT_ABBREVIATED_PARENT_HASHES.$this->data['commit'] |
|
| 54 | - ); |
|
| 55 | - $this->getDateCommit(); |
|
| 56 | - dump($this->data); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * true if there is some data : used by the view |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - public function getGitData() |
|
| 64 | - { |
|
| 65 | - return $this->getData('gitData'); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Actual branch name |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - public function getBranch() |
|
| 73 | - { |
|
| 74 | - return $this->getData('branch'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Commit ID |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - public function getCommit() |
|
| 82 | - { |
|
| 83 | - return $this->getData('commit'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Merge information |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - public function getMerge() |
|
| 91 | - { |
|
| 92 | - return $this->getData('merge'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Merge information |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 99 | - public function getGitDIr() |
|
| 100 | - { |
|
| 101 | - return $this->getData('gitDir'); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Author |
|
| 106 | - * @return string |
|
| 107 | - */ |
|
| 108 | - public function getAuthor() |
|
| 109 | - { |
|
| 110 | - return $this->getData('author'); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Author's email |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 117 | - public function getEmail() |
|
| 118 | - { |
|
| 119 | - return $this->getData('email'); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Commit date |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 126 | - public function getDate() |
|
| 127 | - { |
|
| 128 | - return $this->getData('date'); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Minutes since last commit |
|
| 133 | - * @return string |
|
| 134 | - */ |
|
| 135 | - public function getTimeCommitIntervalMinutes() |
|
| 136 | - { |
|
| 137 | - return $this->getData('timeCommitIntervalMinutes'); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Seconds since latest commit |
|
| 142 | - * @return string |
|
| 143 | - */ |
|
| 144 | - public function getTimeCommitIntervalSeconds() |
|
| 145 | - { |
|
| 146 | - return $this->getData('timeCommitIntervalSeconds'); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Commit message |
|
| 151 | - * @return string |
|
| 152 | - */ |
|
| 153 | - public function getMessage() |
|
| 154 | - { |
|
| 155 | - return $this->getData('message'); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Commit URL |
|
| 160 | - * @return string |
|
| 161 | - */ |
|
| 162 | - public function getCommitUrl() |
|
| 163 | - { |
|
| 164 | - return $this->data['repositoryCommitUrl']; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Checks and returns the data |
|
| 169 | - * @param string $data |
|
| 170 | - * @return string |
|
| 171 | - */ |
|
| 172 | - private function getData($data) |
|
| 173 | - { |
|
| 174 | - |
|
| 175 | - return (isset($this->data[$data])) ? $this->data[$data] : ''; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * DataCollector name : used by service declaration into container.yml |
|
| 180 | - * @return string |
|
| 181 | - */ |
|
| 182 | - public function getName() |
|
| 183 | - { |
|
| 184 | - return 'datacollector_git'; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Change icons color according to the version of symfony |
|
| 189 | - * #3f3f3f < 2.8 |
|
| 190 | - * #AAAAAA >= 2.8 |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 193 | - public function getIconColor() |
|
| 194 | - { |
|
| 195 | - if ((float)$this->getSymfonyVersion() >= 2.8) { |
|
| 196 | - return $this->data['iconColor'] = '#AAAAAA'; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - return $this->data['iconColor'] = '#3F3F3F';#3F3F3F |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return string |
|
| 204 | - */ |
|
| 205 | - private function getSymfonyVersion() |
|
| 206 | - { |
|
| 207 | - $symfonyVersion = \Symfony\Component\HttpKernel\Kernel::VERSION; |
|
| 208 | - $symfonyVersion = explode('.', $symfonyVersion, -1); |
|
| 209 | - $symfonyMajorMinorVersion = implode('.', $symfonyVersion); |
|
| 210 | - |
|
| 211 | - return $symfonyMajorMinorVersion; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - private function verifyExistMergeInCommit() |
|
| 215 | - { |
|
| 216 | - $lastCommit = $this->gitService->exec(GitCommand::GIT_LOG_MINUS_ONE); |
|
| 217 | - if (strpos($lastCommit, 'Merge') === 0) { |
|
| 218 | - // merge information |
|
| 219 | - $this->data['merge'] = trim(substr($lastCommit, 6)); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - private function getDateCommit() |
|
| 224 | - { |
|
| 225 | - $date = $this->gitService->shellExec(GitCommand::GIT_COMMIT_DATE); |
|
| 226 | - $dateCommit = date_create($date); |
|
| 227 | - |
|
| 228 | - // actual date at runtime |
|
| 229 | - $dateRuntime = new \DateTime(); |
|
| 230 | - $dateNow = date_create($dateRuntime->format('Y-m-d H:i:s')); |
|
| 231 | - // difference |
|
| 232 | - $time = date_diff($dateCommit, $dateNow); |
|
| 233 | - |
|
| 234 | - // static time difference : minutes and seconds |
|
| 235 | - $this->data['timeCommitIntervalMinutes'] = $time->format('%y') * 365 * 24 * 60 + $time->format( |
|
| 236 | - '%m' |
|
| 237 | - ) * 30 * 24 * 60 + $time->format('%d') * 24 * 60 + $time->format('%h') * 60 + $time->format('%i'); |
|
| 238 | - // full readable date |
|
| 239 | - $this->data['date'] = $date; |
|
| 240 | - } |
|
| 19 | + private $gitService; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param $repositoryCommitUrl |
|
| 23 | + */ |
|
| 24 | + public function __construct(ContainerInterface $container) |
|
| 25 | + { |
|
| 26 | + $this->gitService = $container->get('debug.toolbar.git'); |
|
| 27 | + $this->data['repositoryCommitUrl'] = $container->getParameter( |
|
| 28 | + 'symfony_debug_toolbar_git.repository_commit_url' |
|
| 29 | + ); |
|
| 30 | + $this->data['gitData'] = true; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Collect Git data for DebugBar (branch,commit,author,email,merge,date,message) |
|
| 35 | + * @param Request $request |
|
| 36 | + * @param Response $response |
|
| 37 | + * @param \Exception $exception |
|
| 38 | + */ |
|
| 39 | + public function collect(Request $request, Response $response, \Exception $exception = null) |
|
| 40 | + { |
|
| 41 | + |
|
| 42 | + if (!file_exists($this->gitService->getGitDir())) { |
|
| 43 | + $this->data['gitData'] = false; |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | + $this->data['gitDir'] = $this->gitService->getGitDir(); |
|
| 47 | + $this->data['branch'] = $this->gitService->shellExec(GitCommand::GIT_CURRENT_BRANCH); |
|
| 48 | + $this->data['commit'] = $this->gitService->shellExec(GitCommand::GIT_HASH_LAST_COMMIT); |
|
| 49 | + $this->data['author'] = $this->gitService->shellExec(GitCommand::GIT_AUTHOR_LAST_COMMIT); |
|
| 50 | + $this->data['email'] = $this->gitService->shellExec(GitCommand::GIT_EMAIL_LAST_COMMIT); |
|
| 51 | + $this->data['message'] = $this->gitService->shellExec(GitCommand::GIT_MESSAGE_LAST_COMMIT); |
|
| 52 | + $this->data['merge'] = $this->gitService->shellExec( |
|
| 53 | + GitCommand::GIT_ABBREVIATED_PARENT_HASHES.$this->data['commit'] |
|
| 54 | + ); |
|
| 55 | + $this->getDateCommit(); |
|
| 56 | + dump($this->data); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * true if there is some data : used by the view |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + public function getGitData() |
|
| 64 | + { |
|
| 65 | + return $this->getData('gitData'); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Actual branch name |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + public function getBranch() |
|
| 73 | + { |
|
| 74 | + return $this->getData('branch'); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Commit ID |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + public function getCommit() |
|
| 82 | + { |
|
| 83 | + return $this->getData('commit'); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Merge information |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + public function getMerge() |
|
| 91 | + { |
|
| 92 | + return $this->getData('merge'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Merge information |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | + public function getGitDIr() |
|
| 100 | + { |
|
| 101 | + return $this->getData('gitDir'); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Author |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 108 | + public function getAuthor() |
|
| 109 | + { |
|
| 110 | + return $this->getData('author'); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Author's email |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | + public function getEmail() |
|
| 118 | + { |
|
| 119 | + return $this->getData('email'); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Commit date |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | + public function getDate() |
|
| 127 | + { |
|
| 128 | + return $this->getData('date'); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Minutes since last commit |
|
| 133 | + * @return string |
|
| 134 | + */ |
|
| 135 | + public function getTimeCommitIntervalMinutes() |
|
| 136 | + { |
|
| 137 | + return $this->getData('timeCommitIntervalMinutes'); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Seconds since latest commit |
|
| 142 | + * @return string |
|
| 143 | + */ |
|
| 144 | + public function getTimeCommitIntervalSeconds() |
|
| 145 | + { |
|
| 146 | + return $this->getData('timeCommitIntervalSeconds'); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Commit message |
|
| 151 | + * @return string |
|
| 152 | + */ |
|
| 153 | + public function getMessage() |
|
| 154 | + { |
|
| 155 | + return $this->getData('message'); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Commit URL |
|
| 160 | + * @return string |
|
| 161 | + */ |
|
| 162 | + public function getCommitUrl() |
|
| 163 | + { |
|
| 164 | + return $this->data['repositoryCommitUrl']; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Checks and returns the data |
|
| 169 | + * @param string $data |
|
| 170 | + * @return string |
|
| 171 | + */ |
|
| 172 | + private function getData($data) |
|
| 173 | + { |
|
| 174 | + |
|
| 175 | + return (isset($this->data[$data])) ? $this->data[$data] : ''; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * DataCollector name : used by service declaration into container.yml |
|
| 180 | + * @return string |
|
| 181 | + */ |
|
| 182 | + public function getName() |
|
| 183 | + { |
|
| 184 | + return 'datacollector_git'; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Change icons color according to the version of symfony |
|
| 189 | + * #3f3f3f < 2.8 |
|
| 190 | + * #AAAAAA >= 2.8 |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | + public function getIconColor() |
|
| 194 | + { |
|
| 195 | + if ((float)$this->getSymfonyVersion() >= 2.8) { |
|
| 196 | + return $this->data['iconColor'] = '#AAAAAA'; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + return $this->data['iconColor'] = '#3F3F3F';#3F3F3F |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 205 | + private function getSymfonyVersion() |
|
| 206 | + { |
|
| 207 | + $symfonyVersion = \Symfony\Component\HttpKernel\Kernel::VERSION; |
|
| 208 | + $symfonyVersion = explode('.', $symfonyVersion, -1); |
|
| 209 | + $symfonyMajorMinorVersion = implode('.', $symfonyVersion); |
|
| 210 | + |
|
| 211 | + return $symfonyMajorMinorVersion; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + private function verifyExistMergeInCommit() |
|
| 215 | + { |
|
| 216 | + $lastCommit = $this->gitService->exec(GitCommand::GIT_LOG_MINUS_ONE); |
|
| 217 | + if (strpos($lastCommit, 'Merge') === 0) { |
|
| 218 | + // merge information |
|
| 219 | + $this->data['merge'] = trim(substr($lastCommit, 6)); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + private function getDateCommit() |
|
| 224 | + { |
|
| 225 | + $date = $this->gitService->shellExec(GitCommand::GIT_COMMIT_DATE); |
|
| 226 | + $dateCommit = date_create($date); |
|
| 227 | + |
|
| 228 | + // actual date at runtime |
|
| 229 | + $dateRuntime = new \DateTime(); |
|
| 230 | + $dateNow = date_create($dateRuntime->format('Y-m-d H:i:s')); |
|
| 231 | + // difference |
|
| 232 | + $time = date_diff($dateCommit, $dateNow); |
|
| 233 | + |
|
| 234 | + // static time difference : minutes and seconds |
|
| 235 | + $this->data['timeCommitIntervalMinutes'] = $time->format('%y') * 365 * 24 * 60 + $time->format( |
|
| 236 | + '%m' |
|
| 237 | + ) * 30 * 24 * 60 + $time->format('%d') * 24 * 60 + $time->format('%h') * 60 + $time->format('%i'); |
|
| 238 | + // full readable date |
|
| 239 | + $this->data['date'] = $date; |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function getIconColor() |
| 194 | 194 | { |
| 195 | - if ((float)$this->getSymfonyVersion() >= 2.8) { |
|
| 195 | + if ((float) $this->getSymfonyVersion() >= 2.8) { |
|
| 196 | 196 | return $this->data['iconColor'] = '#AAAAAA'; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - return $this->data['iconColor'] = '#3F3F3F';#3F3F3F |
|
| 199 | + return $this->data['iconColor'] = '#3F3F3F'; #3F3F3F |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | $time = date_diff($dateCommit, $dateNow); |
| 233 | 233 | |
| 234 | 234 | // static time difference : minutes and seconds |
| 235 | - $this->data['timeCommitIntervalMinutes'] = $time->format('%y') * 365 * 24 * 60 + $time->format( |
|
| 235 | + $this->data['timeCommitIntervalMinutes'] = $time->format('%y')*365*24*60+$time->format( |
|
| 236 | 236 | '%m' |
| 237 | - ) * 30 * 24 * 60 + $time->format('%d') * 24 * 60 + $time->format('%h') * 60 + $time->format('%i'); |
|
| 237 | + )*30*24*60+$time->format('%d')*24*60+$time->format('%h')*60+$time->format('%i'); |
|
| 238 | 238 | // full readable date |
| 239 | 239 | $this->data['date'] = $date; |
| 240 | 240 | } |
@@ -3,17 +3,17 @@ |
||
| 3 | 3 | |
| 4 | 4 | interface GitCommand |
| 5 | 5 | { |
| 6 | - const GIT_LOG_MINUS_ONE = "git log -1"; |
|
| 7 | - const GIT_STATUS = "git status"; |
|
| 8 | - const GIT_CURRENT_BRANCH = "git rev-parse --abbrev-ref HEAD"; |
|
| 9 | - const GIT_COMMIT_COUNT_HEAD = "git rev-list --count HEAD"; |
|
| 6 | + const GIT_LOG_MINUS_ONE = "git log -1"; |
|
| 7 | + const GIT_STATUS = "git status"; |
|
| 8 | + const GIT_CURRENT_BRANCH = "git rev-parse --abbrev-ref HEAD"; |
|
| 9 | + const GIT_COMMIT_COUNT_HEAD = "git rev-list --count HEAD"; |
|
| 10 | 10 | |
| 11 | - //log last commit |
|
| 12 | - const GIT_EMAIL_LAST_COMMIT = "git log -1 --pretty=format:'%cn'"; |
|
| 13 | - const GIT_AUTHOR_LAST_COMMIT = "git log -1 --pretty=format:'%ce'"; |
|
| 14 | - const GIT_HASH_LAST_COMMIT = "git log -1 --pretty=format:' %H'"; |
|
| 15 | - const GIT_MESSAGE_LAST_COMMIT = "git log -1 --pretty=format:' %s'"; |
|
| 16 | - const GIT_ABBREVIATED_PARENT_HASHES = "git log -1 --pretty=%p"; |
|
| 17 | - const GIT_COMMIT_DATE = "git log -1 --pretty=format:'%ad'"; |
|
| 11 | + //log last commit |
|
| 12 | + const GIT_EMAIL_LAST_COMMIT = "git log -1 --pretty=format:'%cn'"; |
|
| 13 | + const GIT_AUTHOR_LAST_COMMIT = "git log -1 --pretty=format:'%ce'"; |
|
| 14 | + const GIT_HASH_LAST_COMMIT = "git log -1 --pretty=format:' %H'"; |
|
| 15 | + const GIT_MESSAGE_LAST_COMMIT = "git log -1 --pretty=format:' %s'"; |
|
| 16 | + const GIT_ABBREVIATED_PARENT_HASHES = "git log -1 --pretty=%p"; |
|
| 17 | + const GIT_COMMIT_DATE = "git log -1 --pretty=format:'%ad'"; |
|
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -5,46 +5,46 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Git |
| 7 | 7 | { |
| 8 | - protected $container; |
|
| 9 | - |
|
| 10 | - public function __construct(ContainerInterface $container) |
|
| 11 | - { |
|
| 12 | - $this->container = $container; |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * verifies that the directory exists |
|
| 17 | - * @return bool |
|
| 18 | - */ |
|
| 19 | - public function getGitDir() |
|
| 20 | - { |
|
| 21 | - $gitDir = $this->container->get('kernel')->getRootDir()."/../"; |
|
| 22 | - $gitDir .= $this->container->getParameter('symfony_debug_toolbar_git.repository_local_dir').'.git'; |
|
| 23 | - |
|
| 24 | - return $gitDir; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param $command |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public function shellExec($command) |
|
| 32 | - { |
|
| 33 | - $command = sprintf('cd %s && %s', $this->getGitDir(), $command); |
|
| 34 | - $resultCommand = shell_exec($command); |
|
| 35 | - |
|
| 36 | - return (string)trim($resultCommand); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @param $command |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - public function exec($command) |
|
| 44 | - { |
|
| 45 | - $command = sprintf('cd %s && %s', $this->getGitDir(), $command); |
|
| 46 | - exec($command, $resultCommand); |
|
| 47 | - |
|
| 48 | - return $resultCommand; |
|
| 49 | - } |
|
| 8 | + protected $container; |
|
| 9 | + |
|
| 10 | + public function __construct(ContainerInterface $container) |
|
| 11 | + { |
|
| 12 | + $this->container = $container; |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * verifies that the directory exists |
|
| 17 | + * @return bool |
|
| 18 | + */ |
|
| 19 | + public function getGitDir() |
|
| 20 | + { |
|
| 21 | + $gitDir = $this->container->get('kernel')->getRootDir()."/../"; |
|
| 22 | + $gitDir .= $this->container->getParameter('symfony_debug_toolbar_git.repository_local_dir').'.git'; |
|
| 23 | + |
|
| 24 | + return $gitDir; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param $command |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public function shellExec($command) |
|
| 32 | + { |
|
| 33 | + $command = sprintf('cd %s && %s', $this->getGitDir(), $command); |
|
| 34 | + $resultCommand = shell_exec($command); |
|
| 35 | + |
|
| 36 | + return (string)trim($resultCommand); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @param $command |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + public function exec($command) |
|
| 44 | + { |
|
| 45 | + $command = sprintf('cd %s && %s', $this->getGitDir(), $command); |
|
| 46 | + exec($command, $resultCommand); |
|
| 47 | + |
|
| 48 | + return $resultCommand; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $command = sprintf('cd %s && %s', $this->getGitDir(), $command); |
| 34 | 34 | $resultCommand = shell_exec($command); |
| 35 | 35 | |
| 36 | - return (string)trim($resultCommand); |
|
| 36 | + return (string) trim($resultCommand); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |