@@ -112,30 +112,29 @@ defmodule Mix.Tasks.Hex.Registry do
112
112
## Add
113
113
114
114
defp add ( public_dir , packages , opts ) do
115
- repo_name_or_nil = opts [ :name ]
116
- private_key_path = opts [ :private_key ] || raise "missing --private-key"
115
+ repo_name = opts [ :name ] || Mix . raise ( "missing --name" )
116
+ private_key_path = opts [ :private_key ] || Mix . raise ( "missing --private-key" )
117
117
private_key = private_key_path |> File . read! ( ) |> decode_private_key ( )
118
- add ( repo_name_or_nil , public_dir , private_key , packages )
118
+ add ( repo_name , public_dir , private_key , packages )
119
119
end
120
120
121
- defp add ( repo_name_or_nil , public_dir , private_key , packages ) do
121
+ defp add ( repo_name , public_dir , private_key , packages ) do
122
122
public_key = ensure_public_key ( private_key , public_dir )
123
123
124
124
existing_names =
125
- read_names! ( repo_name_or_nil , public_dir , public_key )
125
+ read_names! ( repo_name , public_dir , public_key )
126
126
|> Enum . map ( fn % { name: name , updated_at: updated_at } -> { name , updated_at } end )
127
127
|> Enum . into ( % { } )
128
128
129
129
existing_versions =
130
- read_versions! ( repo_name_or_nil , public_dir , public_key )
130
+ read_versions! ( repo_name , public_dir , public_key )
131
131
|> Enum . map ( fn % { name: name , versions: versions } ->
132
132
{ name , % { updated_at: existing_names [ name ] , versions: versions } }
133
133
end )
134
134
|> Enum . into ( % { } )
135
135
136
136
tarball_dir = Path . join ( public_dir , "tarballs" )
137
137
create_directory ( tarball_dir )
138
- repo_name = repo_name_or_nil || read_repository_name! ( public_dir , private_key )
139
138
140
139
paths_per_name =
141
140
packages
@@ -371,23 +370,6 @@ defmodule Mix.Tasks.Hex.Registry do
371
370
end
372
371
end
373
372
374
- defp read_repository_name! ( public_dir , public_key ) do
375
- path = Path . join ( public_dir , "names" )
376
- payload = read_file! ( path )
377
-
378
- case :mix_hex_registry . get_repository_name ( payload , public_key ) do
379
- { :ok , repo_name } ->
380
- repo_name
381
-
382
- _ ->
383
- Mix . raise ( """
384
- Invalid package name manifest at #{ path }
385
-
386
- Is the public key correct?
387
- """ )
388
- end
389
- end
390
-
391
373
defp read_package ( repo_name , public_dir , public_key , package_name ) do
392
374
path = Path . join ( [ public_dir , "packages" , package_name ] )
393
375
0 commit comments