Skip to content

Commit

Permalink
Use scandir() to have a sorted output.
Browse files Browse the repository at this point in the history
$failures is never set here.
  • Loading branch information
yunosh committed Dec 4, 2017
1 parent af35d46 commit acb6a13
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
33 changes: 17 additions & 16 deletions lib/Action/Git/Command.php
Expand Up @@ -48,24 +48,25 @@ public function run(array $commands = array())
}

$this->_dependencies->getOutput()->info('Handling git command.');
foreach (new \DirectoryIterator($this->_params['git_base']) as $it) {
if ($this->_includeRepository($it)) {
foreach ($commands as $cmd) {
if (empty($this->_params['quiet'])) {
$this->_dependencies->getOutput()->plain(
' >>>GIT COMMAND: ' . $cmd
);
}
$results[$it->getFilename()] = $this->_callGit($cmd, $it->getPathname());

if (empty($this->_params['quiet'])) {
$this->_dependencies->getOutput()->plain(
' >>>RESULTS: ' . implode("\n", $results[$it->getFilename()])
);
}
foreach (scandir($this->_params['git_base']) as $dir) {
if (!$this->_includeRepository($dir)) {
continue;
}
foreach ($commands as $cmd) {
if (empty($this->_params['quiet'])) {
$this->_dependencies->getOutput()->plain(
' >>>GIT COMMAND: ' . $cmd
);
}
$results[$dir] = $this->_callGit($cmd, $this->_params['git_base'] . '/' . $dir);

$this->_dependencies->getOutput()->ok('Repository: ' . $it->getFilename() . ' completed.');
if (empty($this->_params['quiet'])) {
$this->_dependencies->getOutput()->plain(
' >>>RESULTS: ' . implode("\n", $results[$dir])
);
}

$this->_dependencies->getOutput()->ok('Repository: ' . $dir . ' completed.');
}
}

Expand Down
36 changes: 19 additions & 17 deletions lib/Action/Git/Pull.php
Expand Up @@ -48,26 +48,28 @@ public function run()
}

$this->_dependencies->getOutput()->info('Starting update of repositories.');
foreach (new \DirectoryIterator($this->_params['git_base']) as $it) {
if ($this->_includeRepository($it)) {
// Debug output
if ($this->_params['verbose']) {
$this->_dependencies->getOutput()->plain(
' >>>GIT COMMAND: ' . $this->_getCommand()
);
}
foreach (scandir($this->_params['git_base']) as $dir) {
if (!$this->_includeRepository($dir)) {
continue;
}

// Debug output
if ($this->_params['verbose']) {
$this->_dependencies->getOutput()->plain(
' >>>GIT COMMAND: ' . $this->_getCommand()
);
}

// Perform pull
$results[$it->getFilename()] = $this->_callGit($this->_getCommand(), $it->getPathname());
// Perform pull
$results[$dir] = $this->_callGit($this->_getCommand(), $this->_params['git_base'] . '/' . $dir);

// Debug output
if ($this->_params['verbose']) {
$this->_dependencies->getOutput()->plain(
' >>>RESULTS: ' . implode("\n", $results[$it->getFilename()])
);
}
$this->_dependencies->getOutput()->ok('Repository: ' . $it->getFilename());
// Debug output
if ($this->_params['verbose']) {
$this->_dependencies->getOutput()->plain(
' >>>RESULTS: ' . implode("\n", $results[$dir])
);
}
$this->_dependencies->getOutput()->ok('Repository: ' . $dir);
}

if (!empty($failures)) {
Expand Down

0 comments on commit acb6a13

Please sign in to comment.