From 5f63ff9dedc83ae67af8f27708c85db0bfc4904c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 26 Aug 2022 10:27:10 +0200 Subject: Allow using other org repos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- label-updater/run.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/label-updater/run.php b/label-updater/run.php index ffe7502..2c9b4a0 100644 --- a/label-updater/run.php +++ b/label-updater/run.php @@ -55,19 +55,25 @@ function getAllLabels($client, $owner, $repo) { $masterLabels = getAllLabels($client, $config['org'], $config['master']); foreach ($repos as $repo) { - $labels = getAllLabels($client, $config['org'], $repo); + $org = $config['org']; + + if (strpos($repo, '/') !== false) { + [$org, $repo] = explode('/', $repo); + } + + $labels = getAllLabels($client, $org, $repo); if ($init) { foreach ($labels as $label) { - $api->deleteLabel($config['org'], $repo, $label['name']); + $api->deleteLabel($org, $repo, $label['name']); } $labels = []; } - print($BOLD . $config['org'] . '/' . $repo . $NO_COLOR . PHP_EOL); + print($BOLD . $org . '/' . $repo . $NO_COLOR . PHP_EOL); foreach ($masterLabels as $masterLabel) { foreach ($config['exclude'] as $exclude) { if (preg_match($exclude, $masterLabel['name'])) { - print(' - ' . $config['org'] . '/' . $repo . ': ' . $STRIKE_THROUGH . $masterLabel['name'] . $NO_COLOR . ' ignoring because of patter ' . $exclude . PHP_EOL); + print(' - ' . $org . '/' . $repo . ': ' . $STRIKE_THROUGH . $masterLabel['name'] . $NO_COLOR . ' ignoring because of patter ' . $exclude . PHP_EOL); continue 2; } } @@ -75,17 +81,18 @@ foreach ($repos as $repo) { foreach ($labels as $label) { if ($label['name'] === $masterLabel['name']) { if ($label['color'] !== $masterLabel['color']) { - print(' - ' . $config['org'] . '/' . $repo . ': Updating color of ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); - $api->update($config['org'], $repo, $label['name'], $label['name'], $masterLabel['color']); + print(' - ' . $org . '/' . $repo . ': Updating color of ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); + $api->update($org, $repo, $label['name'], $masterLabel['name'], $masterLabel['color']); } else { - print(' - ' . $config['org'] . '/' . $repo . ': Skipping ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); + print(' - ' . $org . '/' . $repo . ': Skipping ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); } continue 2; } } - print(' - ' . $config['org'] . '/' . $repo . ': Adding ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); - $api->create($config['org'], $repo, [ + + print(' - ' . $org . '/' . $repo . ': Adding ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); + $api->create($org, $repo, [ 'name' => $masterLabel['name'], 'color' => $masterLabel['color'], ]); -- cgit v1.2.3 From a56c157431af6af7cf302c22cff3be759ad130c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 26 Aug 2022 10:27:30 +0200 Subject: Github label names are case insensitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- label-updater/run.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/label-updater/run.php b/label-updater/run.php index 2c9b4a0..e0329df 100644 --- a/label-updater/run.php +++ b/label-updater/run.php @@ -79,7 +79,7 @@ foreach ($repos as $repo) { } foreach ($labels as $label) { - if ($label['name'] === $masterLabel['name']) { + if (mb_strtolower($label['name']) === mb_strtolower($masterLabel['name'])) { if ($label['color'] !== $masterLabel['color']) { print(' - ' . $org . '/' . $repo . ': Updating color of ' . $masterLabel['name'] . $NO_COLOR . PHP_EOL); $api->update($org, $repo, $label['name'], $masterLabel['name'], $masterLabel['color']); -- cgit v1.2.3