Skip to content

Commit 669be88

Browse files
Change dirty suffix from _dirty to -dirty (#307)
such that it matches the output of `git describe --dirty`. Do so by adding a keyword argument to `gitdescribe()` having that new default. Fix #306
1 parent f46c631 commit 669be88

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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 = "2.7.4"
4+
version = "2.7.5"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/saving_tools.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ export istaggable
77
# Obtaining Git information
88
########################################################################################
99
"""
10-
gitdescribe(gitpath = projectdir()) -> gitstr
10+
gitdescribe(gitpath = projectdir(); dirty_suffix = "-dirty") -> gitstr
1111
1212
Return a string `gitstr` with the output of `git describe` if an annotated git tag exists,
1313
otherwise the current active commit id of the Git repository present
1414
in `gitpath`, which by default is the currently active project. If the repository
1515
is dirty when this function is called the string will end
16-
with `"_dirty"`.
16+
with `dirty_suffix`.
1717
1818
Return `nothing` if `gitpath` is not a Git repository, i.e. a directory within a git
1919
repository.
2020
2121
The format of the `git describe` output in general is
2222
23-
`"TAGNAME-[NUMBER_OF_COMMITS_AHEAD-]gLATEST_COMMIT_HASH[_dirty]"`
23+
`"TAGNAME-[NUMBER_OF_COMMITS_AHEAD-]gLATEST_COMMIT_HASH[-dirty]"`
2424
2525
If the latest tag is `v1.2.3` and there are 5 additional commits while the
2626
latest commit hash is 334a0f225d9fba86161ab4c8892d4f023688159c, the output
@@ -41,10 +41,10 @@ julia> gitdescribe() # a tag doesn't exist
4141
"96df587e45b29e7a46348a3d780db1f85f41de04"
4242
4343
julia> gitdescribe(path_to_a_dirty_repo)
44-
"3bf684c6a115e3dce484b7f200b66d3ced8b0832_dirty"
44+
"3bf684c6a115e3dce484b7f200b66d3ced8b0832-dirty"
4545
```
4646
"""
47-
function gitdescribe(gitpath = projectdir())
47+
function gitdescribe(gitpath = projectdir(); dirty_suffix::String = "-dirty")
4848
# Here we test if the gitpath is a git repository.
4949
try
5050
repo = LibGit2.GitRepoExt(gitpath)
@@ -61,7 +61,7 @@ function gitdescribe(gitpath = projectdir())
6161
end
6262
suffix = ""
6363
if LibGit2.isdirty(repo)
64-
suffix = "_dirty"
64+
suffix = dirty_suffix
6565
@warn "The Git repository ('$gitpath') is dirty! "*
6666
"Appending $(suffix) to the commit ID."
6767
end

test/stools_tests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ dpath = _setup_repo(true) # dirty
2828
cpath = _setup_repo(false) # clean
2929

3030
@test isdirty(dpath)
31-
@test endswith(gitdescribe(dpath), "_dirty")
31+
@test endswith(gitdescribe(dpath), "-dirty")
32+
@test endswith(gitdescribe(dpath, dirty_suffix="-verydirty"), "-verydirty")
33+
@test !endswith(gitdescribe(dpath, dirty_suffix=""), "-dirty")
3234
@test !isdirty(cpath)
33-
@test !endswith(gitdescribe(cpath), "_dirty")
35+
@test !endswith(gitdescribe(cpath), "-dirty")
3436

3537
# tag!
3638
function _test_tag!(d, path, haspatch, DRWATSON_STOREPATCH)

0 commit comments

Comments
 (0)