diff --git a/src/bot.ml b/src/bot.ml index 575609ea..f0732bd3 100644 --- a/src/bot.ml +++ b/src/bot.ml @@ -147,16 +147,7 @@ let callback _conn req body = , coqbot_ci_minimize_text_of_body , coqbot_resume_ci_minimize_text_of_body ) in - let strip_quoted_bot_name body = - (* If someone says "`@coqbot minimize foo`", (with backticks), we - don't want to treat that as them tagging coqbot, so we adjust - the tagging to "@`coqbot minimize foo`" so that the matching - below doesn't pick up the name *) - Str.global_replace - (Str.regexp (f "\\(`\\|\\)@%s " @@ Str.quote github_bot_name)) - (f "@\\1%s " @@ Str.quote github_bot_name) - body - in + let body = Cohttp_lwt.Body.to_string body in (* print_endline "Request received."; *) match Uri.path (Request.uri req) with @@ -308,7 +299,7 @@ let callback _conn req body = Server.respond_string ~status:`OK ~body:"Note card removed from project: nothing to do." () | Ok (_, IssueOpened ({body= Some body} as issue_info)) -> ( - let body = body |> Helpers.trim_comments |> strip_quoted_bot_name in + let body = body |> trim_comments |> strip_quoted_bot_name ~github_bot_name in match coqbot_minimize_text_of_body body with | Some (options, script) -> (fun () -> @@ -329,7 +320,7 @@ let callback _conn req body = () ) | Ok (signed, CommentCreated comment_info) -> ( let body = - comment_info.body |> Helpers.trim_comments |> strip_quoted_bot_name + comment_info.body |> trim_comments |> strip_quoted_bot_name ~github_bot_name in match coqbot_minimize_text_of_body body with | Some (options, script) -> diff --git a/src/helpers.ml b/src/helpers.ml index 0d8acc39..697eef24 100644 --- a/src/helpers.ml +++ b/src/helpers.ml @@ -52,6 +52,23 @@ let trim_comments comment = in aux comment 0 false +let strip_quoted_bot_name ~github_bot_name body = + (* If someone says "`@coqbot minimize foo`", (with backticks), we + don't want to treat that as them tagging coqbot, so we adjust + the tagging to "@`coqbot minimize foo`" so that the matching + below doesn't pick up the name *) + Str.global_replace + (Str.regexp (f "\\(`\\|\\)@%s:? " @@ Str.quote github_bot_name)) + (f "@\\1%s " @@ Str.quote github_bot_name) + body + +let%expect_test "strip_quoted_bot_name" = + Stdio.printf "%s\n" + (strip_quoted_bot_name ~github_bot_name:"coqbot" + {|>this didn't produce a pipeline for some reason\r\n\r\nI think that this is normal. @herbelin was maybe expecting that adding the `request: full CI` label would trigger a new run immediately, but the semantics is that this label will produce such a full CI run at the next update (next push) of this PR. Cf. the [documentation](https://github.com/coq/coq/blob/master/CONTRIBUTING.md#understanding-automatic-feedback):\r\n\r\n>you can request a full run of the CI by putting the `request: full CI` label before pushing to your PR branch, or by commenting `@coqbot: run full CI` after having pushed. |}) ; + [%expect + {| >this didn't produce a pipeline for some reason\r\n\r\nI think that this is normal. @herbelin was maybe expecting that adding the `request: full CI` label would trigger a new run immediately, but the semantics is that this label will produce such a full CI run at the next update (next push) of this PR. Cf. the [documentation](https://github.com/coq/coq/blob/master/CONTRIBUTING.md#understanding-automatic-feedback):\r\n\r\n>you can request a full run of the CI by putting the `request: full CI` label before pushing to your PR branch, or by commenting @`coqbot run full CI` after having pushed. |}] + let github_repo_of_gitlab_project_path ~gitlab_mapping ~gitlab_domain ~gitlab_repo_full_name = let full_name_with_domain = gitlab_domain ^ "/" ^ gitlab_repo_full_name in diff --git a/src/helpers.mli b/src/helpers.mli index 7c2786e5..c3a32fb8 100644 --- a/src/helpers.mli +++ b/src/helpers.mli @@ -20,6 +20,8 @@ val remove_between : string -> int -> int -> string val trim_comments : string -> string +val strip_quoted_bot_name : github_bot_name:string -> string -> string + val github_repo_of_gitlab_project_path : gitlab_mapping:(string, string) Base.Hashtbl.t -> gitlab_domain:string