summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary Hueras <zhueras@chitika.com>2015-09-16 15:20:32 -0400
committerZachary Hueras <zhueras@chitika.com>2015-09-16 15:20:32 -0400
commit1469e59c3afd437debf2f1649e03d814acf5eb1d (patch)
treee3c4f274a505d09267e1a7fe7d03e345616dd3d2 /src
parent82faab2fe7683008a9a11a67abe49dd533916b47 (diff)
Improve semantic versioning from git between tags
In the scenario we that we have selected a commit that is between two tags, we should base the version on the most recent tag we can see in the revision history, but we should not treat this as the tag version. `git describe --tags` finds the most recent tag visible in the revision history from the current HEAD. Return this as the version string and undefined as the tag to trigger ref counting.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_git_resource.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index 0efdd1b..6405e46 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -198,6 +198,12 @@ parse_tags(Dir) ->
{match,[Tag, Vsn]} ->
{Tag, Vsn};
nomatch ->
- {undefined, "0.0.0"}
+ case rebar_utils:sh("git describe --tags",
+ [{use_stdout, false}, return_on_error, {cd, Dir}]) of
+ {error, _} ->
+ {undefined, "0.0.0"};
+ {ok, LatestVsn} ->
+ {undefined, string:strip(LatestVsn, both, $\n)}
+ end
end
end.