Skip to content

Commit 5111513

Browse files
author
José Valim
committed
Clarify usage of version and requires it in releases, closes #9686
1 parent 6760cdb commit 5111513

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

lib/elixir/lib/version.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ defmodule Version do
55
A version is a string in a specific format or a `Version`
66
generated after parsing via `Version.parse/1`.
77
8-
`Version` parsing and requirements follow
9-
[SemVer 2.0 schema](https://semver.org/).
8+
Although Elixir projects are not required to follow SemVer,
9+
they must follow the format outlined on [SemVer 2.0 schema](https://semver.org/).
1010
1111
## Versions
1212
@@ -29,7 +29,7 @@ defmodule Version do
2929
## Struct
3030
3131
The version is represented by the `Version` struct and fields
32-
are named according to SemVer: `:major`, `:minor`, `:patch`,
32+
are named according to SemVer 2.0: `:major`, `:minor`, `:patch`,
3333
`:pre`, and `:build`.
3434
3535
## Requirements

lib/mix/lib/mix/release.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ defmodule Mix.Release do
133133

134134
to_string(version)
135135

136+
"" ->
137+
Mix.raise("The release :version cannot be an empty string")
138+
136139
_ ->
137140
version
138141
end

lib/mix/lib/mix/tasks/compile.app.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ defmodule Mix.Tasks.Compile.App do
200200
ensure_present(:version, version)
201201

202202
unless is_binary(version) and match?({:ok, _}, Version.parse(version)) do
203-
Mix.raise("Expected :version to be a SemVer version, got: #{inspect(version)}")
203+
Mix.raise(
204+
"Expected :version to be a valid Version, got: #{inspect(version)} (see the Version module for more information)"
205+
)
204206
end
205207
end
206208

lib/mix/test/mix/release_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ defmodule Mix.ReleaseTest do
170170
end
171171
end
172172

173+
test "raises for blank version" do
174+
assert_raise Mix.Error, ~r"The release :version cannot be an empty string", fn ->
175+
from_config!(nil, config(version: ""), [])
176+
end
177+
end
178+
173179
test "raises on invalid release names" do
174180
assert_raise Mix.Error, ~r"Invalid release name", fn ->
175181
from_config!(nil, config(releases: ["invalid name": []]), [])

lib/mix/test/mix/tasks/compile.app_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ defmodule Mix.Tasks.Compile.AppTest do
245245
Mix.Project.push(InvalidVsnProject)
246246

247247
in_fixture("no_mixfile", fn ->
248-
message = "Expected :version to be a SemVer version, got: \"0.3\""
248+
message = ~r"Expected :version to be a valid Version, got: \"0.3\""
249249

250250
assert_raise Mix.Error, message, fn ->
251251
Mix.Tasks.Compile.App.run([])

0 commit comments

Comments
 (0)