Tweaking output
This commit is contained in:
parent
d75deea884
commit
082ed23f12
105
chirp.php
105
chirp.php
|
@ -9,9 +9,27 @@ $auth_token = gitea_login($gitea_url, $user, $pass);
|
||||||
if(!$auth_token)
|
if(!$auth_token)
|
||||||
throw new Exception("Could not login to gitea");
|
throw new Exception("Could not login to gitea");
|
||||||
|
|
||||||
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletik', false);
|
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletik',
|
||||||
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletor');
|
array(
|
||||||
gitea_check_base_repo($auth_token, $gitea_url, 'bit/skeletor-rnd');
|
'check_forks' => true,
|
||||||
|
'check_composer' => true,
|
||||||
|
'check_upm' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
gitea_check_base_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',
|
||||||
|
array(
|
||||||
|
'check_forks' => true,
|
||||||
|
'check_composer' => true,
|
||||||
|
'check_upm' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
|
@ -129,57 +147,68 @@ function _is_composer_git_repo(array $repos, $repo)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gitea_check_base_repo($auth_token, $gitea_url, $base_repo, $check_upm = true)
|
function gitea_check_base_repo(
|
||||||
|
$auth_token,
|
||||||
|
$gitea_url,
|
||||||
|
$base_repo,
|
||||||
|
array $opts
|
||||||
|
)
|
||||||
{
|
{
|
||||||
echo "=== Checking base repo '$base_repo' ===\n";
|
echo "************************* Checking base repo '$base_repo' *************************\n";
|
||||||
|
|
||||||
$commits = gitea_get_commits($auth_token, $gitea_url, $base_repo);
|
$commits = gitea_get_commits($auth_token, $gitea_url, $base_repo);
|
||||||
|
|
||||||
$forks = gitea_get_forks($auth_token, $gitea_url, $base_repo);
|
if($opts['check_forks'])
|
||||||
echo "== Checking forks ==\n";
|
|
||||||
foreach($forks as $fork)
|
|
||||||
{
|
{
|
||||||
$repo_fork = $fork['full_name'];
|
$forks = gitea_get_forks($auth_token, $gitea_url, $base_repo);
|
||||||
foreach($commits as $commit)
|
echo "== Checking forks ==\n";
|
||||||
|
foreach($forks as $fork)
|
||||||
{
|
{
|
||||||
$status = gitea_get_commit($auth_token, $gitea_url, $repo_fork, $commit['sha']);
|
$repo_fork = $fork['full_name'];
|
||||||
if($status === null)
|
foreach($commits as $commit)
|
||||||
{
|
{
|
||||||
echo "Fork '$repo_fork' is behind '$base_repo' at ({$commit['sha']}, {$commit['commit']['author']['date']} by {$commit['commit']['author']['name']})\n";
|
$status = gitea_get_commit($auth_token, $gitea_url, $repo_fork, $commit['sha']);
|
||||||
break;
|
if($status === null)
|
||||||
}
|
{
|
||||||
//early exit if commit exists
|
echo "Fork '$repo_fork' is behind\n";
|
||||||
else if(isset($status['sha']))
|
break;
|
||||||
{
|
}
|
||||||
break;
|
//early exit if commit exists
|
||||||
|
else if(isset($status['sha']))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "== Checking Composer manifest ==\n";
|
if($opts['check_composer'])
|
||||||
$composer_json = gitea_get_source($auth_token, $gitea_url, $base_repo, "composer/composer.json");
|
|
||||||
$composer_arr = json_decode($composer_json, true);
|
|
||||||
|
|
||||||
foreach($composer_arr['require'] as $repo => $version)
|
|
||||||
{
|
{
|
||||||
if(strpos($repo, "bit/") !== 0)
|
echo "== Checking Composer manifest ==\n";
|
||||||
continue;
|
$composer_json = gitea_get_source($auth_token, $gitea_url, $base_repo, "composer/composer.json");
|
||||||
|
$composer_arr = json_decode($composer_json, true);
|
||||||
|
|
||||||
if(!_is_composer_git_repo($composer_arr['repositories'], "$gitea_url/$repo"))
|
foreach($composer_arr['require'] as $repo => $version)
|
||||||
continue;
|
|
||||||
|
|
||||||
$tags = gitea_get_tags($auth_token, $gitea_url, $repo);
|
|
||||||
if(isset($tags[0]))
|
|
||||||
{
|
{
|
||||||
$last_tag_info = $tags[0];
|
if(strpos($repo, "bit/") !== 0)
|
||||||
if(ltrim($last_tag_info["name"], 'v') != ltrim($version, 'v'))
|
continue;
|
||||||
echo "Newer version in $repo: current $version, latest {$last_tag_info["name"]}\n";
|
|
||||||
|
if(!_is_composer_git_repo($composer_arr['repositories'], "$gitea_url/$repo"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$tags = gitea_get_tags($auth_token, $gitea_url, $repo);
|
||||||
|
if(isset($tags[0]))
|
||||||
|
{
|
||||||
|
$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";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "Could not fetch tags for $repo\n";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
echo "Could not fetch tags for $repo\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($check_upm)
|
if($opts['check_upm'])
|
||||||
{
|
{
|
||||||
echo "== Checking UPM manifest ==\n";
|
echo "== Checking UPM manifest ==\n";
|
||||||
$upm_json = gitea_get_source($auth_token, $gitea_url, $base_repo, "unity/Packages/manifest.json");
|
$upm_json = gitea_get_source($auth_token, $gitea_url, $base_repo, "unity/Packages/manifest.json");
|
||||||
|
@ -200,7 +229,7 @@ function gitea_check_base_repo($auth_token, $gitea_url, $base_repo, $check_upm =
|
||||||
{
|
{
|
||||||
$last_tag_info = $tags[0];
|
$last_tag_info = $tags[0];
|
||||||
if(ltrim($last_tag_info["name"], 'v') != ltrim($version, 'v'))
|
if(ltrim($last_tag_info["name"], 'v') != ltrim($version, 'v'))
|
||||||
echo "Newer version in $repo: current $version, latest {$last_tag_info["name"]}\n";
|
echo "Package update '$repo': current $version, latest {$last_tag_info["name"]}\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "Could not fetch tags for $repo\n";
|
echo "Could not fetch tags for $repo\n";
|
||||||
|
|
Loading…
Reference in New Issue