1- use anyhow:: Context as Ctx ;
21use crate :: {
3- config:: DecisionConfig ,
4- github:: { Event } ,
5- handlers:: Context ,
2+ config:: DecisionConfig , db:: issue_decision_state:: * , github:: Event , handlers:: Context ,
63 interactions:: ErrorComment ,
7- db:: issue_decision_state:: *
84} ;
5+ use anyhow:: Context as Ctx ;
96use chrono:: { DateTime , Duration , FixedOffset } ;
107use parser:: command:: decision:: { DecisionCommand , Resolution :: * , Reversibility :: * } ;
118use std:: collections:: BTreeMap ;
12- use chrono:: { DateTime , FixedOffset , Duration } ;
139
1410// get state for issue_id from db
1511// if no state (first call)
@@ -33,20 +29,19 @@ pub(super) async fn handle_command(
3329
3430 let DecisionCommand {
3531 resolution,
36- reversibility
32+ reversibility,
3733 } = cmd;
3834
3935 let issue = event. issue ( ) . unwrap ( ) ;
4036 let user = event. user ( ) ;
4137
42- let is_team_member =
43- user
44- . is_team_member ( & ctx. github )
45- . await
46- . unwrap_or ( false ) ;
38+ let is_team_member = user. is_team_member ( & ctx. github ) . await . unwrap_or ( false ) ;
4739
4840 if !is_team_member {
49- let cmnt = ErrorComment :: new ( & issue, "Only team members can be part of the decision process." ) ;
41+ let cmnt = ErrorComment :: new (
42+ & issue,
43+ "Only team members can be part of the decision process." ,
44+ ) ;
5045 cmnt. post ( & ctx. github ) . await ?;
5146 return Ok ( ( ) ) ;
5247 }
@@ -57,41 +52,45 @@ pub(super) async fn handle_command(
5752 // Hold => "hold".into(),
5853 // Custom(name) => name,
5954 // };
60-
55+
6156 // let mut current_statuses = state.current_statuses;
6257 // let mut status_history = state.status_history;
63-
58+
6459 // if let Some(entry) = current_statuses.get_mut(&user) {
6560 // let past = status_history.entry(user).or_insert(Vec::new());
66-
61+
6762 // past.push(entry.clone());
68-
63+
6964 // *entry = UserStatus::new(name, issue_id, comment_id);
7065 // } else {
7166 // current_statuses.insert(user, UserStatus::new("hold".into(), issue_id, comment_id));
7267 // }
73-
68+
7469 // Ok(State {
7570 // current_statuses,
7671 // status_history,
7772 // ..state
7873 // })
7974 Ok ( ( ) )
80- } ,
75+ }
8176 _ => {
8277 match resolution {
8378 Hold => Ok ( ( ) ) , // change me!
8479 Merge => {
8580 let start_date: DateTime < FixedOffset > = chrono:: Utc :: now ( ) . into ( ) ;
86- let end_date: DateTime < FixedOffset > = start_date. checked_add_signed ( Duration :: days ( 10 ) ) . unwrap ( ) ;
81+ let end_date: DateTime < FixedOffset > =
82+ start_date. checked_add_signed ( Duration :: days ( 10 ) ) . unwrap ( ) ;
8783
8884 let mut current: BTreeMap < String , UserStatus > = BTreeMap :: new ( ) ;
89- current. insert ( "mcass19" . to_string ( ) , UserStatus {
90- comment_id : "comment_id" . to_string ( ) ,
91- text : "something" . to_string ( ) ,
92- reversibility : Reversible ,
93- resolution : Merge ,
94- } ) ;
85+ current. insert (
86+ "mcass19" . to_string ( ) ,
87+ UserStatus {
88+ comment_id : "comment_id" . to_string ( ) ,
89+ text : "something" . to_string ( ) ,
90+ reversibility : Reversible ,
91+ resolution : Merge ,
92+ } ,
93+ ) ;
9594 let history: BTreeMap < String , Vec < UserStatus > > = BTreeMap :: new ( ) ;
9695
9796 insert_issue_decision_state (
@@ -104,15 +103,16 @@ pub(super) async fn handle_command(
104103 & history,
105104 & reversibility,
106105 & Merge ,
107- ) . await ?;
106+ )
107+ . await ?;
108108
109109 // let team = github::get_team(&ctx.github, &"T-lang"); // change this to be configurable in toml?
110-
110+
111111 let comment = format ! (
112112 "Wow, it looks like you want to merge this, {}.\n | Team member | State |\n |-------------|-------|\n | julmontesdeoca | merge |\n | mcass19 | |" ,
113113 user. login
114114 ) ;
115-
115+
116116 issue
117117 . post_comment ( & ctx. github , & comment)
118118 . await
0 commit comments