diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df8afb55..88f6b4c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +* The `JuliaHub.update_dataset` function now correctly accepts the `license=(:fulltext, ...)` argument. ([#74]) + ## Version [v0.1.11] - 2024-06-27 ### Added @@ -134,3 +140,4 @@ Initial package release. [#52]: https://github.com/JuliaComputing/JuliaHub.jl/issues/52 [#53]: https://github.com/JuliaComputing/JuliaHub.jl/issues/53 [#58]: https://github.com/JuliaComputing/JuliaHub.jl/issues/58 +[#74]: https://github.com/JuliaComputing/JuliaHub.jl/issues/74 diff --git a/Project.toml b/Project.toml index eca3cde93..9e8a9d961 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JuliaHub" uuid = "bc7fa6ce-b75e-4d60-89ad-56c957190b6e" authors = ["JuliaHub Inc."] -version = "0.1.11" +version = "0.1.12-DEV" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/datasets.jl b/src/datasets.jl index 160340d8c..f4c7441fe 100644 --- a/src/datasets.jl +++ b/src/datasets.jl @@ -465,9 +465,15 @@ const _DOCS_datasets_metadata_fields = """ * `description`: description of the dataset (a string) * `tags`: an iterable of strings of all the tags of the dataset * `visibility`: a string with possible values `public` or `private` -* `license`: a valid SPDX license identifier, or a tuple `(:fulltext, license_text)`, where - `license_text` is the full text string of a custom license +* `license`: a valid SPDX license identifier (as a string or in a + `(:spdx, licence_identifier)` tuple), or a tuple `(:fulltext, license_text)`, + where `license_text` is the full text string of a custom license * `groups`: an iterable of valid group names + +!!! compat "JuliaHub.jl v0.1.12" + + The `license = (:fulltext, ...)` form requires v0.1.12, and `license = (:text, ...)` + is deprecated since that version. """ """ @@ -983,7 +989,14 @@ function update_dataset end cmd, license_value = license params["license"] = if cmd == :spdx Dict("spdx_id" => license_value) - elseif cmd == :text + elseif cmd in (:fulltext, :text) + if cmd == :text + Base.depwarn( + "Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.", + :update_dataset; + force=true, + ) + end Dict("text" => license_value) else throw(ArgumentError("Invalid license argument: $(cmd) ∉ [:spdx, :text]")) diff --git a/test/datasets.jl b/test/datasets.jl index 59ec2161d..2506f2242 100644 --- a/test/datasets.jl +++ b/test/datasets.jl @@ -237,6 +237,24 @@ end @test_throws TypeError JuliaHub.update_dataset( "example-dataset"; description=42 ) + # Different options for `license` keyword + @test JuliaHub.update_dataset("example-dataset"; license="MIT") isa JuliaHub.Dataset + @test JuliaHub.update_dataset("example-dataset"; license=(:spdx, "MIT")) isa + JuliaHub.Dataset + @test JuliaHub.update_dataset("example-dataset"; license=(:fulltext, "...")) isa + JuliaHub.Dataset + # This should log a deprecation warning + @test @test_logs ( + :warn, + "Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.", + ) JuliaHub.update_dataset( + "example-dataset"; license=(:text, "...") + ) isa JuliaHub.Dataset + @test_throws TypeError JuliaHub.update_dataset("example-dataset"; license=1234) + @test_throws ArgumentError JuliaHub.update_dataset("example-dataset"; license=(:foo, "")) + @test_throws TypeError JuliaHub.update_dataset( + "example-dataset"; license=(:fulltext, 1234) + ) end end @@ -293,6 +311,33 @@ end # @test JuliaHub.upload_dataset( # "existing-dataset", @__FILE__; update=true) isa JuliaHub.Dataset + + # Different options for `license` keyword + @test JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; create=true, license="MIT" + ) isa JuliaHub.Dataset + @test JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=(:spdx, "MIT") + ) isa JuliaHub.Dataset + @test JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=(:fulltext, "...") + ) isa JuliaHub.Dataset + # This should log a deprecation warning + @test @test_logs ( + :warn, + "Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.", + ) JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=(:text, "...") + ) isa JuliaHub.Dataset + @test_throws TypeError JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=1234 + ) + @test_throws ArgumentError JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=(:foo, "") + ) + @test_throws TypeError JuliaHub.upload_dataset( + "example-dataset-license", @__FILE__; replace=true, license=(:fulltext, 1234) + ) end empty!(MOCK_JULIAHUB_STATE) end