Bläddra i källkod

Optionally parse colon after to in relabel command

Mark Rousskov 5 år sedan
förälder
incheckning
88420a7f05
1 ändrade filer med 17 tillägg och 0 borttagningar
  1. 17 0
      parser/src/command/relabel.rs

+ 17 - 0
parser/src/command/relabel.rs

@@ -141,6 +141,11 @@ impl RelabelCommand {
             toks.next_token()?;
         } else if let Some(Token::Word("to")) = toks.peek_token()? {
             toks.next_token()?;
+            // optionally eat the colon after to, e.g.:
+            // @rustbot modify labels to: -S-waiting-on-author, +S-waiting-on-review
+            if let Ok(Some(Token::Colon)) = toks.peek_token() {
+                toks.next_token()?;
+            }
         } else {
             return Err(toks.error(ParseError::NoSeparator));
         }
@@ -226,3 +231,15 @@ fn parse_no_dot() {
         ]))
     );
 }
+
+#[test]
+fn parse_to_colon() {
+    assert_eq!(
+        parse("modify labels to: +T-compiler -T-lang bug"),
+        Ok(Some(vec![
+            LabelDelta::Add(Label("T-compiler".into())),
+            LabelDelta::Remove(Label("T-lang".into())),
+            LabelDelta::Add(Label("bug".into())),
+        ]))
+    );
+}