spenserblack/gengo

Automate adding the `new-language` label to PRs for a new language

Closed this issue · 0 comments

This should add the new-language label if a new entry is added to languages.yaml, and not if an entry is renamed or deleted. Also, it should only label PRs with 1 new language. Kind of like this:

// oldLanguages is read from `languages.yaml` after `git checkout HEAD^`
const oldEntries = new Set(Object.entries(oldLanguages));
const newEntries = new Set(Object.entries(newLanguages));
const added = Array.from(newEntries).filter((entry) => !oldEntries.has(entry));
const removed = Array.from(oldEntries).filter((entry) => !newEntries.has(entry));
const shouldLabel = added.length === 1 && removed.length === 0;