This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5d8182f60e GH-14796: [Dev] Prepend missing "[COMPONENT]" to issue 
title automatically (#49892)
5d8182f60e is described below

commit 5d8182f60ec98fa3e7bb5316efa999df53a6f1a6
Author: Nic Crane <[email protected]>
AuthorDate: Wed Apr 29 20:50:20 2026 -0400

    GH-14796: [Dev] Prepend missing "[COMPONENT]" to issue title automatically 
(#49892)
    
    ### Rationale for this change
    
    Easier to see which issues are related to which component when we add the 
component to the title automatically if it's missing
    
    ### What changes are included in this PR?
    
    Add code to do so
    
    ### Are these changes tested?
    
    Yep - look at issues open at www.github.com/thisisnic/arrow
    
    ### Are there any user-facing changes?
    
    Nope
    * GitHub Issue: #14796
    
    Authored-by: Nic Crane <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 .github/workflows/issue_bot.yml | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/.github/workflows/issue_bot.yml b/.github/workflows/issue_bot.yml
index 3e5b2a4dcf..32e5effab3 100644
--- a/.github/workflows/issue_bot.yml
+++ b/.github/workflows/issue_bot.yml
@@ -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!');
 
@@ -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,

Reply via email to