Skip to content

Commit 3b6a473

Browse files
committed
allow key type Any in tag!
1 parent f23c25d commit 3b6a473

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# 1.0.1
2+
* Allow `tag!` and derivatives to handle dictionaries with *key type* `Any`.
13
# 1.0.0
24
First major release (no notable change from 0.8.0).
35

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DrWatson"
22
uuid = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1"
33
repo = "https://github.com/JuliaDynamics/DrWatson.jl.git"
4-
version = "1.0.0"
4+
version = "1.0.1"
55

66

77
[deps]

src/saving_files.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the macros [`@dict`](@ref) and [`@strdict`](@ref) can help with that.
2121
file, but only checks if it exists. The return value in this case is always
2222
`nothing, s`, regardless of whether the file exists or not. If it doesn't
2323
exist it is still produced and saved.
24-
* `verbose = true` : print info about the process.
24+
* `verbose = true` : print info about the process, if the file doesn't exist.
2525
* `kwargs...` : All other keywords are propagated to `savename`.
2626
2727
See also [`savename`](@ref).

src/saving_tools.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,37 @@ function tag!(d::Dict{K, T}, gitpath = projectdir(), storepatch = true, source =
126126

127127
c = gitdescribe(gitpath)
128128
patch = gitpatch(gitpath)
129+
@assert (Symbol <: K) || (String <: K)
130+
if K == Symbol
131+
commitname, patchname, scriptname = :gitcommit, :gitpatch, :script
132+
else
133+
commitname, patchname, scriptname = "gitcommit", "gitpatch", "script"
134+
end
135+
129136
c === nothing && return d # gitpath is not a git repo
130-
if haskey(d, K("gitcommit"))
137+
if haskey(d, commitname)
131138
@warn "The dictionary already has a key named `gitcommit`. We won't "*
132139
"add any Git information."
133140
return d
134141
end
135142
if String <: T
136-
d[K("gitcommit")] = c
143+
d[commitname] = c
137144
if patch!=""
138-
d[K("gitpatch")] = patch
145+
d[patchname] = patch
139146
end
140147
else
141148
d = Dict{K, promote_type(T, String)}(d)
142-
d[K("gitcommit")] = c
149+
d[commitname] = c
143150
if patch!=""
144-
d[K("gitpatch")] = patch
151+
d[patchname] = patch
145152
end
146153
end
147154
if source != nothing
148-
if haskey(d, K("script"))
155+
if haskey(d, scriptname)
149156
@warn "The dictionary already has a key named `script`. We won't "*
150157
"overwrite it with the script name."
151158
else
152-
d[K("script")] = relpath(sourcename(source), gitpath)
159+
d[scriptname] = relpath(sourcename(source), gitpath)
153160
end
154161
end
155162
return d

0 commit comments

Comments
 (0)