Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/github_helper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-08-26 11:48:29 +0300
committerGitHub <noreply@github.com>2022-08-26 11:48:29 +0300
commita6bd6eff8f9ba20b8eeaabd1f7f516c20e360153 (patch)
tree99b51e2a1bb89c62df6c2258d16ae9a23f0e323b
parent7ed3c2a6de81a60406ed7acd4b208b5acc8b2d14 (diff)
parenta56c157431af6af7cf302c22cff3be759ad130c4 (diff)
Merge pull request #64 from nextcloud/enh/label-updater
Make label updater work across organizations
-rw-r--r--label-updater/run.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/label-updater/run.php b/label-updater/run.php
index ffe7502..e0329df 100644
--- a/label-updater/run.php
+++ b/label-updater/run.php
@@ -55,37 +55,44 @@ 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;
}
}
foreach ($labels as $label) {
- if ($label['name'] === $masterLabel['name']) {
+ if (mb_strtolower($label['name']) === mb_strtolower($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'],
]);