From 5eb714e1d33e92d48eda2bbb824a1414d2d8ccc8 Mon Sep 17 00:00:00 2001 From: Julian Montes de Oca Date: Wed, 26 Oct 2022 15:18:44 -0300 Subject: [PATCH] fix parse to test integration --- parser/src/command/decision.rs | 9 ++++++--- src/handlers/decision.rs | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/parser/src/command/decision.rs b/parser/src/command/decision.rs index 31e22c978..c6a6df18c 100644 --- a/parser/src/command/decision.rs +++ b/parser/src/command/decision.rs @@ -8,7 +8,7 @@ //! Command: `@bot merge`, `@bot hold`, `@bot restart`, `@bot dissent`, `@bot stabilize` or `@bot close`. //! ``` -use crate::token::{Tokenizer}; +use crate::token::{Token, Tokenizer}; use crate::error::Error; use serde::{Deserialize, Serialize}; use postgres_types::{FromSql, ToSql}; @@ -22,11 +22,14 @@ pub struct DecisionCommand { } impl DecisionCommand { - pub fn parse<'a>(_input: &mut Tokenizer<'a>) -> Result, Error<'a>> { + pub fn parse<'a>(input: &mut Tokenizer<'a>) -> Result, Error<'a>> { + if let Some(Token::Word("merge")) = input.peek_token()? { Ok(Some(Self { resolution: Resolution::Merge, reversibility: Reversibility::Reversible - })) + })) } else { + Ok(None) + } } } diff --git a/src/handlers/decision.rs b/src/handlers/decision.rs index 6dfa27c78..3644c3cf8 100644 --- a/src/handlers/decision.rs +++ b/src/handlers/decision.rs @@ -1,3 +1,4 @@ +use anyhow::Context as Ctx; use parser::command::decision::{DecisionCommand, ParseError}; use crate::{ config::DecisionConfig, @@ -46,8 +47,6 @@ pub(super) async fn handle_command( return Ok(()); } - // return Ok(()); - match get_decision_state(issue.id) { Some(state) => { // let name = match disposition { @@ -73,7 +72,7 @@ pub(super) async fn handle_command( // status_history, // ..state // }) - Ok() + Ok(); }, None => { match resolution { @@ -98,6 +97,20 @@ pub(super) async fn handle_command( reversibility, resolution, ); + + let comment = format!( + "Wow, it looks like you want to merge this, {}.", event.user().login + ); + + let comment = format!( + "| Team member | State |\n|-------------|-------|\n| julmontesdeoca | merge |\n| mcass19 | |"); + + issue + .post_comment(&ctx.github, &comment) + .await + .context("merge vote comment")?; + + Ok(); } } }