Last active
November 4, 2015 13:45
-
-
Save anroots/f28ff18d5a601e74eb38 to your computer and use it in GitHub Desktop.
What does this do?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Client; include 'vendor/autoload.php'; define('ROOT', 'https://stash.local'); $sp7a9ef4 = array('API', 'AD', 'AP', 'SERVICE', 'API-UTIL'); $sp33c1bb = array(); foreach ($sp7a9ef4 as $sp0e38ee) { $sp09795d = new Client(); $sp6171a0 = sprintf(ROOT . '/rest/api/1.0/projects/%s/repos', $sp0e38ee); $sp8e6701 = $sp09795d->request('GET', $sp6171a0, array('auth' => array(getenv('LDAP_USER'), getenv('LDAP_PASS')))); $sp1478c4 = json_decode($sp8e6701->getBody(), true); foreach ($sp1478c4['values'] as $spb0932d) { if (!isset($sp33c1bb[$sp0e38ee])) { $sp33c1bb[$sp0e38ee] = array(); } $sp33c1bb[$sp0e38ee][] = $spb0932d['slug']; } } $sp976d5b = array(); foreach ($sp33c1bb as $sp0e38ee => $spf4b9a8) { foreach ($spf4b9a8 as $sp5f4662) { $sp6171a0 = sprintf(ROOT . '/rest/api/1.0/projects/%s/repos/%s/pull-requests', $sp0e38ee, $sp5f4662); $sp09795d = new Client(); $sp8e6701 = $sp09795d->request('GET', $sp6171a0, array('auth' => array(getenv('LDAP_USER'), getenv('LDAP_PASS')))); $sp1478c4 = json_decode($sp8e6701->getBody(), true); if (!count($sp1478c4['values'])) { continue; } foreach ($sp1478c4['values'] as $spb0932d) { if (!isset($spb0932d['id']) || !isset($spb0932d['reviewers']) || empty($spb0932d['reviewers'])) { continue; } foreach ($spb0932d['reviewers'] as $sp350e5f) { if ($sp350e5f['role'] == 'REVIEWER' && $sp350e5f['approved'] == false && $sp350e5f['user']['name'] == getenv('LDAP_USER')) { $sp976d5b[] = array($sp0e38ee, $sp5f4662, $spb0932d['id']); } } } } } unset($sp09795d, $sp1478c4, $sp0e38ee, $sp7a9ef4, $sp5f4662, $sp33c1bb, $spf4b9a8, $sp8e6701, $sp350e5f, $spb0932d, $sp6171a0); if (empty($sp976d5b)) { echo 'No requests found'; die; } else { echo 'Processing requests: ' . print_r($sp976d5b, true); } foreach ($sp976d5b as $sp26446c) { $sp09795d = new Client(); $sp6171a0 = $sp6171a0 = sprintf(ROOT . '/rest/api/1.0/projects/%s/repos/%s/pull-requests/%s/approve', $sp26446c[0], $sp26446c[1], $sp26446c[2]); echo $sp6171a0 . PHP_EOL; $sp8e6701 = $sp09795d->request('POST', $sp6171a0, array('auth' => array(getenv('LDAP_USER'), getenv('LDAP_PASS')))); $sp09795d = new Client(); $sp6171a0 = $sp6171a0 = sprintf(ROOT . '/rest/api/1.0/projects/%s/repos/%s/pull-requests/%s/comments', $sp26446c[0], $sp26446c[1], $sp26446c[2]); $sp8e6701 = $sp09795d->request('POST', $sp6171a0, array('auth' => array(getenv('LDAP_USER'), getenv('LDAP_PASS')), 'form_params' => array('text' => 'Looks good! :)'))); $sp09795d = new Client(); $sp8e6701 = $sp09795d->request('POST', 'https://fleep.io/hook/s74JQGJmTTax1bI7EWx-GQ', array('form_params' => array('message' => sprintf('Request %s looks good! :)', $sp6171a0)))); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export NO_PROXY=stash.local | |
export HTTPS_PROXY=http://proxy.local:3128 | |
export LDAP_PASS='pass' | |
export LDAP_user='user' | |
if [ ! -d "vendor" ]; then | |
echo "`crontab -l`\n*/2 9-18 * * 1-6 php `pwd`/run.php" | crontab | |
composer require guzzlehttp/guzzle | |
fi | |
php run.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment