Adding --dry-run mode which once enabled prevents sending reports to Slack

This commit is contained in:
Pavel Shevaev 2022-08-30 15:19:13 +03:00
parent 404df850f5
commit 197990479c
2 changed files with 11 additions and 5 deletions

View File

@ -221,8 +221,9 @@ function gitea_check_repo(
) )
{ {
$r = new Reporters(); $r = new Reporters();
$r->add(new SlackReporter());
$r->add(new CliReporter()); $r->add(new CliReporter());
if($opts['log_to_slack'])
$r->add(new SlackReporter());
$r->write("************************* Chirping about repo '$base_repo' *************************\n"); $r->write("************************* Chirping about repo '$base_repo' *************************\n");

View File

@ -5,6 +5,7 @@ $user = getenv('GITEA_USER');
$pass = getenv('GITEA_PASS'); $pass = getenv('GITEA_PASS');
$gitea_url = 'https://git.bit5.ru'; $gitea_url = 'https://git.bit5.ru';
$log_to_slack = !in_array('--dry-run', $argv);
$auth_token = hoopoe\gitea_login($gitea_url, $user, $pass); $auth_token = hoopoe\gitea_login($gitea_url, $user, $pass);
if(!$auth_token) if(!$auth_token)
@ -14,28 +15,32 @@ hoopoe\gitea_check_repo($auth_token, $gitea_url, 'bit/skeletik',
array( array(
'check_forks' => true, 'check_forks' => true,
'check_composer' => true, 'check_composer' => true,
'check_upm' => false 'check_upm' => false,
'log_to_slack' => $log_to_slack,
) )
); );
hoopoe\gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor', hoopoe\gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor',
array( array(
'check_forks' => true, 'check_forks' => true,
'check_composer' => true, 'check_composer' => true,
'check_upm' => true 'check_upm' => true,
'log_to_slack' => $log_to_slack,
) )
); );
hoopoe\gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor-rnd', hoopoe\gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor-rnd',
array( array(
'check_forks' => true, 'check_forks' => true,
'check_composer' => true, 'check_composer' => true,
'check_upm' => true 'check_upm' => true,
'log_to_slack' => $log_to_slack,
) )
); );
hoopoe\gitea_check_repo($auth_token, $gitea_url, 'game/gymmania', hoopoe\gitea_check_repo($auth_token, $gitea_url, 'game/gymmania',
array( array(
'check_forks' => false, 'check_forks' => false,
'check_composer' => true, 'check_composer' => true,
'check_upm' => false 'check_upm' => false,
'log_to_slack' => $log_to_slack,
) )
); );