Skip to content

Commit

Permalink
context: ignore scheme when looking for repo secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Khady committed Aug 7, 2024
1 parent 66188f9 commit 8928db1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ let find_repo_config_exn ctx repo_url =

let set_repo_config ctx repo_url config = Stringtbl.replace ctx.config repo_url config

let gh_repo_of_secrets (secrets : Config_t.secrets) repo_url =
let drop_scheme url =
let uri = Uri.of_string url in
Uri.with_scheme uri None
in
let repo = drop_scheme repo_url in
match List.find_opt (fun r -> Uri.equal (drop_scheme r.Config_t.url) repo) secrets.repos with
| None -> None
| Some repos -> Some repos

let gh_token_of_secrets (secrets : Config_t.secrets) repo_url =
match List.find_opt (fun r -> String.equal r.Config_t.url repo_url) secrets.repos with
match gh_repo_of_secrets secrets repo_url with
| None -> None
| Some repos -> repos.gh_token

let gh_hook_secret_token_of_secrets (secrets : Config_t.secrets) repo_url =
match List.find_opt (fun r -> String.equal r.Config_t.url repo_url) secrets.repos with
match gh_repo_of_secrets secrets repo_url with
| None -> None
| Some repos -> repos.gh_hook_secret

Expand Down

1 comment on commit 8928db1

@rr0gi
Copy link
Contributor

@rr0gi rr0gi commented on 8928db1 Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should drop scheme when looking for secret but use the scheme from config when contacting gh, this will solve redirect problem ?

Please sign in to comment.