Skip to content

Commit 19cc0d1

Browse files
committed
add context flag verbose to suppress config printing during tests
1 parent bdaa5e8 commit 19cc0d1

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
@@ -201,7 +201,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
201201
match%lwt Github_api.get_config ~ctx ~repo with
202202
| Ok config ->
203203
State.set_repo_config ctx.state ~repo_url:repo.url ~config;
204-
Context.print_config ctx repo.url;
204+
if ctx.verbose then Context.print_config ctx repo.url;
205205
Lwt.return @@ Ok ()
206206
| Error e -> action_error e
207207
in

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
@@ -76,9 +79,11 @@ let refresh_state ctx =
7679
let print_config ctx repo_url =
7780
let cfg = State.find_repo_config_exn ctx.state repo_url in
7881
let secrets = get_secrets_exn ctx in
79-
let token = gh_hook_token_of_secrets secrets repo_url in
80-
log#info "using prefix routing:";
82+
let hook_token = gh_hook_token_of_secrets secrets repo_url in
83+
let token = gh_token_of_secrets secrets repo_url in
84+
Stdio.print_endline "using prefix routing:";
8185
Rule.Prefix.print_prefix_routing cfg.prefix_rules.rules;
82-
log#info "using label routing:";
86+
Stdio.print_endline "using label routing:";
8387
Rule.Label.print_label_routing cfg.label_rules.rules;
84-
log#info "signature checking %s" (if Option.is_some token then "enabled" else "disabled")
88+
Stdio.printf "signature checking %s\n" (if Option.is_some hook_token then "enabled" else "disabled");
89+
Stdio.printf "personal access token %s\n" (if Option.is_some token then "enabled" else "disabled")

0 commit comments

Comments
 (0)