Skip to content

Commit 273467c

Browse files
committed
Propagate oauth_exchange to organization repos
Organization repos inherit config from their parent via default_organization but oauth_exchange and oauth_exchange_url were not being propagated. This meant org repos like hexpm:rtpacnroll never had the oauth_exchange key set, falling back to the default of false in build_hex_core_config instead of inheriting true from hexpm.
1 parent 2520243 commit 273467c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

lib/hex/repo.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@ defmodule Hex.Repo do
4848
public_key = merge_values(Map.get(repo, :public_key), source.public_key)
4949
auth_key = merge_values(Map.get(repo, :auth_key), source.auth_key)
5050

51+
oauth_exchange =
52+
merge_values(Map.get(repo, :oauth_exchange), Map.get(source, :oauth_exchange))
53+
54+
oauth_exchange_url =
55+
merge_values(Map.get(repo, :oauth_exchange_url), Map.get(source, :oauth_exchange_url))
56+
5157
repo
5258
|> Map.put(:url, url)
5359
|> Map.put(:public_key, public_key)
5460
|> Map.put(:auth_key, auth_key)
61+
|> Map.put(:oauth_exchange, oauth_exchange)
62+
|> Map.put(:oauth_exchange_url, oauth_exchange_url)
5563
|> Map.put(:trusted, Map.has_key?(repo, :auth_key) or source.trusted)
5664
end
5765

test/hex/repo_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ defmodule Hex.RepoTest do
107107
assert {:ok,
108108
%{
109109
auth_key: nil,
110+
oauth_exchange: true,
110111
public_key: _,
111112
trusted: true,
112113
url: "http://localhost:4043/repo/repos/acme"
@@ -126,6 +127,7 @@ defmodule Hex.RepoTest do
126127
assert {:ok,
127128
%{
128129
auth_key: "key",
130+
oauth_exchange: true,
129131
public_key: _,
130132
trusted: true,
131133
url: "http://example.com/repos/acme"
@@ -145,6 +147,7 @@ defmodule Hex.RepoTest do
145147
assert {:ok,
146148
%{
147149
auth_key: "key",
150+
oauth_exchange: true,
148151
public_key: _,
149152
trusted: false,
150153
url: "http://example.com/repos/acme"
@@ -160,6 +163,7 @@ defmodule Hex.RepoTest do
160163
url: "http://example.com",
161164
public_key: "public",
162165
auth_key: "auth",
166+
oauth_exchange: true,
163167
trusted: true
164168
},
165169
"hexpm:acme" => %{}
@@ -168,6 +172,7 @@ defmodule Hex.RepoTest do
168172
assert %{
169173
"hexpm:acme" => %{
170174
auth_key: "auth",
175+
oauth_exchange: true,
171176
public_key: "public",
172177
trusted: true,
173178
url: "http://example.com/repos/acme"

0 commit comments

Comments
 (0)