Pārlūkot izejas kodu

Prepend issue titles to Zulip topics

Zulip doesn't have a lot of space for the topic title, and we want the most
distinguishing bit first. This is the issue title, not the number (which is too
opaque).
Mark Rousskov 5 gadi atpakaļ
vecāks
revīzija
c3f1156520
1 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 7 2
      src/handlers/major_change.rs

+ 7 - 2
src/handlers/major_change.rs

@@ -138,8 +138,13 @@ async fn handle_input(
     labels.push(github::Label { name: label_to_add });
     let github_req = issue.set_labels(&ctx.github, labels);
 
-    let mut zulip_topic = format!("{} {}", issue.zulip_topic_reference(), issue.title);
-    zulip_topic.truncate(60); // Zulip limitation
+    let mut zulip_topic = format!(" {}", issue.zulip_topic_reference());
+    // We prepend the issue title, truncating such that the overall length does
+    // not exceed 60 characters (a Zulip limitation).
+    zulip_topic.insert_str(
+        0,
+        &issue.title[..std::cmp::min(issue.title.len(), 60 - zulip_topic.len())],
+    );
 
     let zulip_stream = config.zulip_stream.to_string();
     let zulip_req = crate::zulip::MessageApiRequest {