Skip to content

Commit 050821a

Browse files
authored
Show the user event link in the table that triggered the vote (#11)
* Fix top comment in decision parser * Display vote with link to the event that caused it
1 parent 8bf9368 commit 050821a

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

parser/src/command/decision.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
//! The decision process command parser.
22
//!
3-
//! This can parse arbitrary input, giving the user to be assigned.
3+
//! This can parse arbitrary input, giving the command with which we would like
4+
//! to vote that will potentially change the issue in its resolution,
5+
//! reversibility and/or more.
6+
//!
7+
//! In the first one, we must also assign a valid team to the issue decision process.
48
//!
59
//! The grammar is as follows:
610
//!
711
//! ```text
8-
//! Command: `@bot merge`, `@bot hold`, `@bot restart`, `@bot dissent`, `@bot stabilize` or `@bot close`.
12+
//! Command: `@bot merge`, `@bot hold`, `@bot close`
13+
//!
14+
//! First comment: `@bot merge lang`, `@bot hold lang`
915
//! ```
1016
1117
use std::fmt;

src/handlers/decision.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ fn build_status_comment(
161161
match history.get(user) {
162162
Some(statuses) => {
163163
for status in statuses {
164-
let status_item = format!(" ~~{}~~ ", status.resolution);
164+
let status_item =
165+
format!(" [~~{}~~]({}) ", status.resolution, status.comment_id);
165166
user_statuses.push_str(&status_item);
166167
}
167168
}
@@ -170,7 +171,7 @@ fn build_status_comment(
170171

171172
// current status
172173
let user_resolution = match status {
173-
Some(status) => format!("**{}**", status.resolution),
174+
Some(status) => format!("[**{}**]({})", status.resolution, status.comment_id),
174175
_ => "".to_string(),
175176
};
176177

@@ -190,13 +191,14 @@ mod tests {
190191

191192
factori!(UserStatus, {
192193
default {
193-
comment_id = "the-comment-id".to_string(),
194+
comment_id = "https://some-comment-id-for-merge.com".to_string(),
194195
text = "this is my argument for making this decision".to_string(),
195196
reversibility = Reversibility::Reversible,
196197
resolution = Resolution::Merge
197198
}
198199

199200
mixin hold {
201+
comment_id = "https://some-comment-id-for-hold.com".to_string(),
200202
resolution = Resolution::Hold
201203
}
202204
});
@@ -228,8 +230,8 @@ mod tests {
228230
.expect("it shouldn't fail building the message");
229231
let expected_comment = "| Team member | State |\n\
230232
|-------------|-------|\n\
231-
| @Barbara | ~~hold~~ ~~merge~~ **merge** |\n\
232-
| @Niklaus | ~~merge~~ ~~hold~~ **merge** |"
233+
| @Barbara | [~~hold~~](https://some-comment-id-for-hold.com) [~~merge~~](https://some-comment-id-for-merge.com) [**merge**](https://some-comment-id-for-merge.com) |\n\
234+
| @Niklaus | [~~merge~~](https://some-comment-id-for-merge.com) [~~hold~~](https://some-comment-id-for-hold.com) [**merge**](https://some-comment-id-for-merge.com) |"
233235
.to_string();
234236

235237
assert_eq!(build_result, expected_comment);
@@ -267,8 +269,8 @@ mod tests {
267269
.expect("it shouldn't fail building the message");
268270
let expected_comment = "| Team member | State |\n\
269271
|-------------|-------|\n\
270-
| @Barbara | ~~hold~~ ~~merge~~ **merge** |\n\
271-
| @Niklaus | ~~merge~~ ~~hold~~ **merge** |\n\
272+
| @Barbara | [~~hold~~](https://some-comment-id-for-hold.com) [~~merge~~](https://some-comment-id-for-merge.com) [**merge**](https://some-comment-id-for-merge.com) |\n\
273+
| @Niklaus | [~~merge~~](https://some-comment-id-for-merge.com) [~~hold~~](https://some-comment-id-for-hold.com) [**merge**](https://some-comment-id-for-merge.com) |\n\
272274
| @Tom | |"
273275
.to_string();
274276

@@ -330,8 +332,8 @@ mod tests {
330332
.expect("it shouldn't fail building the message");
331333
let expected_comment = "| Team member | State |\n\
332334
|-------------|-------|\n\
333-
| @Barbara | **merge** |\n\
334-
| @Niklaus | **merge** |\
335+
| @Barbara | [**merge**](https://some-comment-id-for-merge.com) |\n\
336+
| @Niklaus | [**merge**](https://some-comment-id-for-merge.com) |\
335337
"
336338
.to_string();
337339

0 commit comments

Comments
 (0)