Skip to content

Commit f29b471

Browse files
authored
Merge pull request #783 from JonathanBrouwer/parse_note
Parse `note=` for notes on priorities and rollup
2 parents 573b1fb + ae022ba commit f29b471

3 files changed

Lines changed: 47 additions & 6 deletions

File tree

src/bors/command/parser.rs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ fn parser_priority(command: &CommandPart<'_>, parts: &[CommandPart<'_>]) -> Pars
521521
Ok(p) => p,
522522
Err(e) => return Some(Err(e)),
523523
};
524-
let note = join_parts(parts);
524+
let note = parse_note(parts);
525525
Some(Ok(BorsCommand::SetPriority { priority, note }))
526526
}
527527

@@ -550,7 +550,7 @@ fn parser_rollup(command: &CommandPart<'_>, parts: &[CommandPart<'_>]) -> ParseR
550550
Ok(r) => r,
551551
Err(e) => return Some(Err(e)),
552552
};
553-
let note = join_parts(parts);
553+
let note = parse_note(parts);
554554
Some(Ok(BorsCommand::SetRollupMode { rollup_mode, note }))
555555
}
556556

@@ -594,6 +594,13 @@ fn parser_tree_ops(command: &CommandPart<'_>, parts: &[CommandPart<'_>]) -> Pars
594594
}
595595
}
596596

597+
fn parse_note(parts: &[CommandPart<'_>]) -> Option<String> {
598+
match parts {
599+
&[CommandPart::KeyValue { key: "note", value }] => Some(value.to_string()),
600+
parts => join_parts(parts),
601+
}
602+
}
603+
597604
/// Join all the command parts into a single string.
598605
/// If there are no other parts, returns `None`.
599606
fn join_parts(parts: &[CommandPart<'_>]) -> Option<String> {
@@ -1012,6 +1019,23 @@ mod tests {
10121019
);
10131020
}
10141021

1022+
#[test]
1023+
fn parse_priority_explicit_note() {
1024+
let cmds = parse_commands("@bors p=1 note=a");
1025+
insta::assert_debug_snapshot!(cmds, @r#"
1026+
[
1027+
Ok(
1028+
SetPriority {
1029+
priority: 1,
1030+
note: Some(
1031+
"a",
1032+
),
1033+
},
1034+
),
1035+
]
1036+
"#);
1037+
}
1038+
10151039
#[test]
10161040
fn parse_priority_unknown_arg() {
10171041
let cmds = parse_commands("@bors p=1 a");
@@ -1244,6 +1268,23 @@ mod tests {
12441268
"#);
12451269
}
12461270

1271+
#[test]
1272+
fn parse_rollup_explicit_note() {
1273+
let cmds = parse_commands("@bors rollup note=a");
1274+
insta::assert_debug_snapshot!(cmds, @r#"
1275+
[
1276+
Ok(
1277+
SetRollupMode {
1278+
rollup_mode: Always,
1279+
note: Some(
1280+
"a",
1281+
),
1282+
},
1283+
),
1284+
]
1285+
"#);
1286+
}
1287+
12471288
#[test]
12481289
fn parse_rollup_unknown_arg() {
12491290
let cmds = parse_commands("@bors rollup a");

src/bors/handlers/help.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ mod tests {
3838
- You can pass a comma-separated list of GitHub usernames.
3939
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
4040
- `r-`: Unapprove this PR
41-
- `p=<priority> [note]` | `priority=<priority> [<note>]`: Set the priority of this PR
41+
- `p=<priority> [note=[<note>]]` | `priority=<priority> [note=[<note>]]`: Set the priority of this PR
4242
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
43-
- `rollup=<never|iffy|maybe|always> [<note>]`: Set the rollup status of the PR
43+
- `rollup=<never|iffy|maybe|always> [note=[<note>]]`: Set the rollup status of the PR
4444
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
4545
- `rollup`: Short for `rollup=always`
4646
- `rollup-`: Short for `rollup=maybe`

src/bors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ You can use the following commands:
104104
- You can pass a comma-separated list of GitHub usernames.
105105
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
106106
- `r-`: Unapprove this PR
107-
- `p=<priority> [note]` | `priority=<priority> [<note>]`: Set the priority of this PR
107+
- `p=<priority> [note=[<note>]]` | `priority=<priority> [note=[<note>]]`: Set the priority of this PR
108108
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
109-
- `rollup=<never|iffy|maybe|always> [<note>]`: Set the rollup status of the PR
109+
- `rollup=<never|iffy|maybe|always> [note=[<note>]]`: Set the rollup status of the PR
110110
- Optionally, you can attach a `<note>` to the PR that will be displayed on the queue page.
111111
- `rollup`: Short for `rollup=always`
112112
- `rollup-`: Short for `rollup=maybe`

0 commit comments

Comments
 (0)