Skip to content

Commit 4670f0e

Browse files
committed
add context flag verbose to suppress config printing during tests
1 parent 64c4582 commit 4670f0e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/action.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
200200
let fetch_config () =
201201
match%lwt Github_api.get_config ~ctx ~repo with
202202
| Ok config ->
203-
Context.print_config ctx repo.url;
203+
if ctx.verbose then Context.print_config ctx repo.url;
204204
State.set_repo_config ctx.state ~repo_url:repo.url ~config;
205205
Lwt.return @@ Ok ()
206206
| Error e -> action_error e

lib/context.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type t = {
1212
state_filepath : string option;
1313
mutable secrets : Config_t.secrets option;
1414
state : State_t.state;
15+
verbose : bool;
1516
}
1617

1718
let default : t =
@@ -21,12 +22,14 @@ let default : t =
2122
state_filepath = None;
2223
secrets = None;
2324
state = State.empty ();
25+
verbose = true;
2426
}
2527

26-
let make ?config_filename ?secrets_filepath ?state_filepath () =
28+
let make ?config_filename ?secrets_filepath ?state_filepath ?verbose () =
2729
let config_filename = Option.value config_filename ~default:default.config_filename in
2830
let secrets_filepath = Option.value secrets_filepath ~default:default.secrets_filepath in
29-
{ default with config_filename; secrets_filepath; state_filepath }
31+
let verbose = Option.value verbose ~default:default.verbose in
32+
{ default with config_filename; secrets_filepath; state_filepath; verbose }
3033

3134
let get_secrets_exn ctx =
3235
match ctx.secrets with
@@ -74,9 +77,11 @@ let refresh_state ctx =
7477
let print_config ctx repo_url =
7578
let cfg = State.find_repo_config_exn ctx.state repo_url in
7679
let secrets = get_secrets_exn ctx in
77-
let token = gh_hook_token_of_secrets secrets repo_url in
78-
log#info "using prefix routing:";
80+
let hook_token = gh_hook_token_of_secrets secrets repo_url in
81+
let token = gh_token_of_secrets secrets repo_url in
82+
Stdio.print_endline "using prefix routing:";
7983
Rule.Prefix.print_prefix_routing cfg.prefix_rules.rules;
80-
log#info "using label routing:";
84+
Stdio.print_endline "using label routing:";
8185
Rule.Label.print_label_routing cfg.label_rules.rules;
82-
log#info "signature checking %s" (if Option.is_some token then "enabled" else "disabled")
86+
Stdio.printf "signature checking %s\n" (if Option.is_some hook_token then "enabled" else "disabled");
87+
Stdio.printf "personal access token %s\n" (if Option.is_some token then "enabled" else "disabled")

0 commit comments

Comments
 (0)