Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/issue_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ jobs:
`Thanks for your report! The ${component} implementation has moved to https://github.com/apache/${repo}.\n\n` +
`This issue has been closed automatically - please open a new issue there.`;

let component_to_prefix = (component) => {
const prefix_overrides = {
"Continuous Integration": "CI",
"Developer Tools": "Dev",
"Documentation": "Docs",
};
return prefix_overrides[component] || component;
};

let title_has_prefix = (title, prefix) => {
return title.includes(`[${prefix}]`);
};

let split_body = context.payload.issue.body.split('### Component(s)');
if (split_body.length != 2) throw new Error('No components found!');

Expand Down Expand Up @@ -104,6 +117,30 @@ jobs:

if (component_labels.length == 0) throw new Error('No components found!');

let component_prefixes = component_labels.map(
label => component_to_prefix(label.substring("Component: ".length))
);

let issue_title = context.payload.issue.title.trimStart();

let missing_prefixes = component_prefixes.filter(
prefix => !title_has_prefix(issue_title, prefix)
);

let missing_title_prefix = missing_prefixes
.map(prefix => `[${prefix}]`)
.join("");

if (missing_title_prefix) {
let title_separator = issue_title.startsWith("[") ? "" : " ";
await github.rest.issues.update({
"owner": context.repo.owner,
"repo": context.repo.repo,
"issue_number": context.payload.issue.number,
"title": missing_title_prefix + title_separator + issue_title,
});
}

await github.rest.issues.setLabels({
"owner": context.repo.owner,
"repo": context.repo.repo,
Expand Down