Tweaking output

This commit is contained in:
Pavel Shevaev 2022-08-29 14:18:09 +03:00
parent 082ed23f12
commit 20ad03f44e
1 changed files with 17 additions and 9 deletions

View File

@ -9,28 +9,34 @@ $auth_token = gitea_login($gitea_url, $user, $pass);
if(!$auth_token)
throw new Exception("Could not login to gitea");
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletik',
gitea_check_repo($auth_token, $gitea_url, 'bit/skeletik',
array(
'check_forks' => true,
'check_composer' => true,
'check_upm' => false
)
);
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletor',
gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor',
array(
'check_forks' => true,
'check_composer' => true,
'check_upm' => true
)
);
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletor-rnd',
gitea_check_repo($auth_token, $gitea_url, 'bit/skeletor-rnd',
array(
'check_forks' => true,
'check_composer' => true,
'check_upm' => true
)
);
gitea_check_repo($auth_token, $gitea_url, 'game/gymmania',
array(
'check_forks' => false,
'check_composer' => true,
'check_upm' => false
)
);
//////////////////////////////////
function gitea_login($gitea_url, $user, $pass)
@ -147,20 +153,21 @@ function _is_composer_git_repo(array $repos, $repo)
return false;
}
function gitea_check_base_repo(
function gitea_check_repo(
$auth_token,
$gitea_url,
$base_repo,
array $opts
)
{
echo "************************* Checking base repo '$base_repo' *************************\n";
echo "************************* Checking repo '$base_repo' *************************\n";
$commits = gitea_get_commits($auth_token, $gitea_url, $base_repo);
if($opts['check_forks'])
{
$forks = gitea_get_forks($auth_token, $gitea_url, $base_repo);
$behind_forks = array();
echo "== Checking forks ==\n";
foreach($forks as $fork)
{
@ -170,7 +177,7 @@ function gitea_check_base_repo(
$status = gitea_get_commit($auth_token, $gitea_url, $repo_fork, $commit['sha']);
if($status === null)
{
echo "Fork '$repo_fork' is behind\n";
$behind_forks[] = $repo_fork;
break;
}
//early exit if commit exists
@ -180,6 +187,7 @@ function gitea_check_base_repo(
}
}
}
echo "Behind forks: " . implode(", ", $behind_forks) . "\n";
}
if($opts['check_composer'])
@ -201,7 +209,7 @@ function gitea_check_base_repo(
{
$last_tag_info = $tags[0];
if(ltrim($last_tag_info["name"], 'v') != ltrim($version, 'v'))
echo "Package update '$repo': current $version, latest {$last_tag_info["name"]}\n";
echo "Package '$repo': current $version, latest {$last_tag_info["name"]}\n";
}
else
echo "Could not fetch tags for $repo\n";
@ -229,7 +237,7 @@ function gitea_check_base_repo(
{
$last_tag_info = $tags[0];
if(ltrim($last_tag_info["name"], 'v') != ltrim($version, 'v'))
echo "Package update '$repo': current $version, latest {$last_tag_info["name"]}\n";
echo "Package '$repo': current $version, latest {$last_tag_info["name"]}\n";
}
else
echo "Could not fetch tags for $repo\n";