# Give every forge the labels of the first one in forges.toml, then# label each mirrored issue as it is labelled there (by its title).use io;
use lists;
use strings;
import"./forges.j"as forges;
import"@deckyard/codehost/"as codehost;
def sites aslistofforges.Site initforges.load();
def src asforges.Site init$sites[0];
def wanted aslistofcodehost.Label initcodehost.labels($src.forge, $src.repo);
def issues aslistofcodehost.Issue initcodehost.issues($src.forge, $src.repo, "open");
for (def s in$sites[1..len($sites)]) {
def f ascodehost.Forge init$s.forge;
def have aslistofstringinit [];
for (def l incodehost.labels($f, $s.repo)) {
$have[] = $l.name;
}
for (def l in$wanted) {
if (notlists.contains($have, $l.name)) {
codehost.createLabel(
$f, $s.repo, $l.name, $l.color, $l.description);
io.printf("%s: created %s\n", $f.backend, $l.name);
}
}
for (def mine incodehost.issues($f, $s.repo, "open")) {
for (def i in$issues) {
if ($i.title == $mine.title) {
def now aslistofstringinitcodehost.setIssueLabels(
$f, $s.repo, $mine.number, $i.labels);
io.printf("%s: #%d %s\n",
$f.backend, $mine.number, strings.join($now, ", "));
}
}
}
}