Skip to content

Commit ae8fd7a

Browse files
committed
remove dead code
1 parent ecd8711 commit ae8fd7a

File tree

2 files changed

+2
-85
lines changed

2 files changed

+2
-85
lines changed

lib/github.ml

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ open Devkit
33
open Printf
44
open Github_j
55

6-
exception Remote_config_error of string
7-
8-
let remote_config_error fmt = ksprintf (fun s -> raise (Remote_config_error s)) fmt
9-
10-
let log = Log.from "github"
11-
126
type t =
137
| Push of commit_pushed_notification
148
| Pull_request of pr_notification
@@ -38,63 +32,10 @@ let commits_branch_of_ref ref =
3832
| _ -> ref
3933

4034
let event_of_filename filename =
41-
match String.split_on_chars filename ~on:[ '.' ] with
42-
| [ kind; _name; ext ] when String.equal ext "json" -> Some kind
43-
| _ -> None
44-
45-
let api_url_of_repo (repo : repository) =
46-
Option.map ~f:(fun host ->
47-
match host with
48-
| "api.github.com" -> sprintf "https://%s" host
49-
| _ -> sprintf "https://%s/api/v3" host)
50-
@@ Uri.host
51-
@@ Uri.of_string repo.url
52-
53-
let user_of_full_name_parts full_name_parts =
54-
match full_name_parts with
55-
| user :: _ -> Some user
35+
match String.split_on_chars ~on:[ '.' ] filename with
36+
| [ kind; _; "json" ] -> Some kind
5637
| _ -> None
5738

58-
let name_of_full_name_parts full_name_parts =
59-
match full_name_parts with
60-
| _ :: repo_name :: _ -> Some repo_name
61-
| _ -> None
62-
63-
let get_remote_config_json_url filename ?token req =
64-
let repo = repo_of_notification req in
65-
match String.split ~on:'/' repo.full_name with
66-
| full_name_parts ->
67-
match user_of_full_name_parts full_name_parts with
68-
| None -> remote_config_error "unable to resolve repository owner"
69-
| Some owner ->
70-
match name_of_full_name_parts full_name_parts with
71-
| None -> remote_config_error "unable to resolve repository name"
72-
| Some repo_name ->
73-
match api_url_of_repo repo with
74-
| None -> remote_config_error "unable to resolve github api url from repository url"
75-
| Some base_url ->
76-
let url = sprintf "%s/repos/%s/%s/contents/%s" base_url owner repo_name filename in
77-
begin
78-
match token with
79-
| None -> url
80-
| Some token -> sprintf "%s?access_token=%s" url token
81-
end
82-
83-
let config_of_content_api_response response =
84-
try%lwt
85-
match response.encoding with
86-
| "base64" ->
87-
Lwt.return
88-
@@ Config_j.config_of_string
89-
@@ Common.decode_string_pad
90-
@@ String.concat
91-
@@ String.split_lines
92-
@@ response.content
93-
| e -> remote_config_error "unknown encoding format '%s'" e
94-
with
95-
| Base64.Invalid_char -> remote_config_error "unable to decode configuration file from base64"
96-
| Yojson.Json_error msg -> remote_config_error "unable to parse configuration file as valid JSON (%s)" msg
97-
9839
let is_main_merge_message ~msg:message ~branch (cfg : Config.t) =
9940
match cfg.main_branch_name with
10041
| Some main_branch when String.equal branch main_branch ->
@@ -123,24 +64,6 @@ let is_valid_signature ~secret headers_sig body =
12364
let (`Hex request_hash) = Hex.of_string request_hash in
12465
String.equal headers_sig (sprintf "sha1=%s" request_hash)
12566

126-
let load_config_json url =
127-
let headers = [ "Accept: application/vnd.github.v3+json" ] in
128-
match%lwt Web.http_request_lwt ~headers `GET url with
129-
| `Error e -> remote_config_error "error while querying github api %s: %s" url e
130-
| `Ok s -> config_of_content_api_response @@ Github_j.content_api_response_of_string s
131-
132-
let query_api ?token ~url parse =
133-
let headers = Option.map token ~f:(fun t -> [ sprintf "Authorization: token %s" t ]) in
134-
match%lwt Web.http_request_lwt ~ua:"notabot" ~verbose:true ?headers `GET url with
135-
| `Error e ->
136-
log#error "error while querying github api %s: %s" url e;
137-
Lwt.return_none
138-
| `Ok s ->
139-
try Lwt.return_some (parse s)
140-
with exn ->
141-
log#error ~exn "impossible to parse github api answer to %s" url;
142-
Lwt.return_none
143-
14467
(* Parse a payload. The type of the payload is detected from the headers. *)
14568
let parse_exn ~secret headers body =
14669
begin

lib/slack.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,3 @@ let generate_commit_comment_notification api_commit notification =
353353
in
354354
let notifs = { text = None; attachments = Some [ attachment ]; blocks = None } in
355355
Lwt.return notifs
356-
357-
let send_notification webhook_url data =
358-
let body = `Raw ("application/json", data) in
359-
match%lwt Web.http_request_lwt ~verbose:true ~body `POST webhook_url with
360-
| `Ok _ -> Lwt.return_unit
361-
| `Error e -> Exn_lwt.fail "failed to send notification to slack : %s" e

0 commit comments

Comments
 (0)