@@ -88,7 +88,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
88
88
89
89
let partition_status (ctx : Context.t ) (n : status_notification ) =
90
90
let repo = n.repository in
91
- let cfg = State . find_repo_config_exn ctx.state repo.url in
91
+ let cfg = Context . find_repo_config_exn ctx repo.url in
92
92
let pipeline = n.context in
93
93
let current_status = n.state in
94
94
let rules = cfg.status_rules.rules in
@@ -111,8 +111,8 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
111
111
| Ok commit -> Lwt. return @@ partition_commit cfg commit.files
112
112
)
113
113
in
114
- if State . is_pipeline_allowed ctx.state repo.url ~pipeline then begin
115
- let repo_state = State. find_repo_exn ctx.state repo.url in
114
+ if Context . is_pipeline_allowed ctx repo.url ~pipeline then begin
115
+ let repo_state = State. find_or_add_repo ctx.state repo.url in
116
116
match Rule.Status. match_rules ~rules n with
117
117
| Some Ignore | None -> Lwt. return []
118
118
| Some Allow -> action_on_match n.branches
@@ -131,7 +131,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
131
131
else Lwt. return []
132
132
133
133
let partition_commit_comment (ctx : Context.t ) n =
134
- let cfg = State . find_repo_config_exn ctx.state n.repository.url in
134
+ let cfg = Context . find_repo_config_exn ctx n.repository.url in
135
135
match n.comment.commit_id with
136
136
| None -> action_error " unable to find commit id for this commit comment event"
137
137
| Some sha ->
@@ -151,7 +151,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
151
151
152
152
let generate_notifications (ctx : Context.t ) req =
153
153
let repo = Github. repo_of_notification req in
154
- let cfg = State . find_repo_config_exn ctx.state repo.url in
154
+ let cfg = Context . find_repo_config_exn ctx repo.url in
155
155
match req with
156
156
| Github. Push n ->
157
157
partition_push cfg n |> List. map ~f: (fun (channel , n ) -> generate_push_notification n channel) |> Lwt. return
@@ -181,20 +181,19 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
181
181
Lwt_list. iter_s notify notifications
182
182
183
183
(* * `refresh_repo_config ctx n` fetches the latest repo config if it's
184
- uninitialized in state , or if the incoming request `n` is a push
184
+ uninitialized, or if the incoming request `n` is a push
185
185
notification containing commits that touched the config file. *)
186
186
let refresh_repo_config (ctx : Context.t ) notification =
187
187
let repo = Github. repo_of_notification notification in
188
188
let fetch_config () =
189
189
match % lwt Github_api. get_config ~ctx ~repo with
190
190
| Ok config ->
191
- State . set_repo_config ctx.state ~repo_url: repo.url ~ config ;
191
+ Context . set_repo_config ctx repo.url config;
192
192
Context. print_config ctx repo.url;
193
193
Lwt. return @@ Ok ()
194
194
| Error e -> action_error e
195
195
in
196
- let repo_state = State. find_or_add_repo ctx.state repo.url in
197
- match repo_state.config with
196
+ match Context. find_repo_config ctx repo.url with
198
197
| None -> fetch_config ()
199
198
| Some _ ->
200
199
match notification with
@@ -251,9 +250,6 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
251
250
| Context. Context_error msg ->
252
251
log#error " %s" msg;
253
252
Lwt. return_unit
254
- | State. State_error msg ->
255
- log#error " %s" msg;
256
- Lwt. return_unit
257
253
258
254
let process_link_shared_event (ctx : Context.t ) (event : Slack_t.link_shared_event ) =
259
255
let process link =
0 commit comments