Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#387 #398

Merged
merged 12 commits into from
Sep 28, 2023
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.13.7
Datseris marked this conversation as resolved.
Show resolved Hide resolved
- Add `commmit_message` option in `tag!`, which add an additional `"gitmessage"` field in dictionary `d` and include the git message associated with the commit.

# 2.12.6
- Crucial bugfix to `produce_or_load`. When used with a prefix, it attached double prefix to the file (one coming as a duplicate from `savename`). This is now fixed, but it means that some files produced with prefix and `produce_or_load` in v2.12 may be re-produced after this update.

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DrWatson"
uuid = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1"
repo = "https://github.com/JuliaDynamics/DrWatson.jl.git"
version = "2.12.7"
version = "2.13.7"
Datseris marked this conversation as resolved.
Show resolved Hide resolved

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
5 changes: 3 additions & 2 deletions src/saving_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ the project's gitpath). Do nothing if a key `gitcommit` already exists
repository is not found. If the git repository is dirty, i.e. there
are un-commited changes, and `storepatch` is true, then the output of `git diff HEAD` is stored
in the field `gitpatch`. Note that patches for binary files are not
stored. You can use [`isdirty`](@ref) to check if a repo is dirty. If the `commit message` is set to `true`,
then the output will display the commit message.
stored. You can use [`isdirty`](@ref) to check if a repo is dirty.
If the `commit message` is set to `true`,
then the dictionary `d` will include an additional field `"gitmessage"` and will contain the git message associated with the commit.

Notice that the key-type of the dictionary must be `String` or `Symbol`.
If `String` is a subtype of the _value_ type of the dictionary, this operation is
Expand Down
31 changes: 14 additions & 17 deletions test/stools_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cpath = _setup_repo(false) # clean
@test !endswith(gitdescribe(cpath), "-dirty")

# tag!
function _test_tag!(d, path, haspatch, hasmessage, DRWATSON_STOREPATCH)
function _test_tag!(d, path, haspatch, DRWATSON_STOREPATCH)
d = copy(d)
withenv("DRWATSON_STOREPATCH" => DRWATSON_STOREPATCH) do
d = tag!(d, gitpath=path; commit_message = true)
Expand All @@ -48,13 +48,6 @@ function _test_tag!(d, path, haspatch, hasmessage, DRWATSON_STOREPATCH)
@test d[patchname] isa String
@test d[patchname] != ""
end
if hasmessage
message_name = keytype(d)(:gitmessage)
@test haskey(d, message_name)
@test d[message_name] isa String
@test d[message_name] != ""
@test d[message_name] == "tmp repo commit"
end
end
end

Expand All @@ -63,19 +56,23 @@ d2 = Dict("x" => 3, "y" => 4)
@testset "tag! ($(keytype(d)))" for d in (d1, d2)
@testset "no patch ($(dirty ? "dirty" : "clean"))" for dirty in (true, false)
path = dirty ? dpath : cpath
_test_tag!(d, path, false, false, nothing) # variable unset
_test_tag!(d, path, false, false, "") # variable set but empty
_test_tag!(d, path, false, false, "false") # variable parses as false
_test_tag!(d, path, false, false, "0") # variable parses as false
_test_tag!(d, path, false, false, "rubbish") # variable not a Bool
_test_tag!(d, path, false, nothing) # variable unset
_test_tag!(d, path, false, "") # variable set but empty
_test_tag!(d, path, false, "false") # variable parses as false
_test_tag!(d, path, false, "0") # variable parses as false
_test_tag!(d, path, false, "rubbish") # variable not a Bool
end
@testset "patch" begin
_test_tag!(d, dpath, true, false, "true") # variable parses as true
_test_tag!(d, dpath, true, false, "1") # variable parses as true
_test_tag!(d, dpath, true, "true") # variable parses as true
_test_tag!(d, dpath, true, "1") # variable parses as true
end
@testset "message" begin
Datseris marked this conversation as resolved.
Show resolved Hide resolved
_test_tag!(d, dpath, true, false, "true")
_test_tag!(d, dpath, true, true, "true")
d = copy(d1)
path = cpath
d = tag!(d; gitpath=path, commit_message = true)
message_name = keytype(d)(:gitmessage)
@test haskey(d, message_name)
@test d[message_name] == "tmp repo commit"
end
end

Expand Down