Skip to content

Commit

Permalink
allow more than one repository in the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
christofdamian committed Jan 28, 2014
1 parent da8e304 commit b9c1cc9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 61 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGES
=======

0.5.0
-----
* allow more than one repository in the config file

0.4.0
-----
* new token:create command to create github authorization token
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ authorization:
password: secret
token: githubtoken

repository:
username: christofdamian
name: test
status: true
required: 3
whitelist: [ christofdamian ]
repositories:
-
username: christofdamian
name: test
status: true
required: 3
whitelist: [ christofdamian ]
```
Credits
Expand Down
121 changes: 66 additions & 55 deletions src/PlusPull/Commands/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,63 +55,74 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
}

$username = $config['repository']['username'];
$repository = $config['repository']['name'];
$checkStatus = !empty($config['repository']['status']);

$plusRequired = 3;
if (!empty($config['repository']['required'])) {
$plusRequired = $config['repository']['required'];
}

$whitelist = null;
if (!empty($config['repository']['whitelist'])) {
$whitelist = $config['repository']['whitelist'];
}

$maxPulls = $input->getOption('limit');

$github->setRepository($username, $repository);

foreach ($github->getPullRequests() as $pullRequest) {
$pull = $input->getOption('pull');

$output->write($pullRequest->number.' ('.$pullRequest->title.')');

if ($pullRequest->checkComments($plusRequired, $whitelist)) {
$output->write(' +1');
} else {
$output->write(' -1');
$pull = false;
}

if ($checkStatus) {
if ($pullRequest->checkStatuses()) {
$output->write(' success');
} else {
$output->write(' fail');
$pull = false;
}
}

if ($pullRequest->isMergeable()) {
$output->write(' mergeable');
} else {
$output->write(' conflicts');
$pull = false;
}

if ($pull) {
$github->merge($pullRequest->number);
$output->write(' pulled');
$maxPulls--;
}

$output->writeln('');

if ($maxPulls<=0) {
break;
}
if (!empty($config['repository'])) {
$repositories = array($config['repository']);
} else {
$repositories = $config['repositories'];
}

foreach ($repositories as $repositoryConfig) {

$username = $repositoryConfig['username'];
$repository = $repositoryConfig['name'];
$checkStatus = !empty($repositoryConfig['status']);

$output->writeln("repository: $username/$repository");

$plusRequired = 3;
if (!empty($repositoryConfig['required'])) {
$plusRequired = $repositoryConfig['required'];
}

$whitelist = null;
if (!empty($repositoryConfig['whitelist'])) {
$whitelist = $repositoryConfig['whitelist'];
}

$github->setRepository($username, $repository);

foreach ($github->getPullRequests() as $pullRequest) {
$pull = $input->getOption('pull');

$output->write($pullRequest->number.' ('.$pullRequest->title.')');

if ($pullRequest->checkComments($plusRequired, $whitelist)) {
$output->write(' +1');
} else {
$output->write(' -1');
$pull = false;
}

if ($checkStatus) {
if ($pullRequest->checkStatuses()) {
$output->write(' success');
} else {
$output->write(' fail');
$pull = false;
}
}

if ($pullRequest->isMergeable()) {
$output->write(' mergeable');
} else {
$output->write(' conflicts');
$pull = false;
}

if ($pull) {
$github->merge($pullRequest->number);
$output->write(' pulled');
$maxPulls--;
}

$output->writeln('');

if ($maxPulls<=0) {
break;
}
}
}
}
}

0 comments on commit b9c1cc9

Please sign in to comment.