diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2011-02-18 10:59:57 +0100 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-02-18 10:59:57 +0100 |
commit | 6056c63eed288736c912c82d6f36aa7dd055f9ca (patch) | |
tree | 174193ae08d2824164ba99e63f696a6593ee63c6 /src | |
parent | 01a7473dac44befe05c460e28c601e2eec785b41 (diff) |
Clean up and simplify {vsn, VCS} support
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_utils.erl | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index f50ac86..27b9176 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -89,13 +89,7 @@ app_applications(AppFile) -> app_vsn(AppFile) -> case load_app_file(AppFile) of {ok, _, AppInfo} -> - case get_value(vsn, AppInfo, AppFile) of - git -> vcs_vsn(git); - hg -> vcs_vsn(hg); - bzr -> vcs_vsn(bzr); - svn -> vcs_vsn(svn); - Version -> Version - end; + vcs_vsn(get_value(vsn, AppInfo, AppFile)); {error, Reason} -> ?ABORT("Failed to extract vsn from ~s: ~p\n", [AppFile, Reason]) @@ -132,11 +126,16 @@ get_value(Key, AppInfo, AppFile) -> end. vcs_vsn(Vcs) -> - Cmd = vcs_vsn_cmd(Vcs), - {ok, VsnString} = rebar_utils:sh(Cmd, [{use_stdout, false}]), - string:strip(VsnString, right, $\n). + case vcs_vsn_cmd(Vcs) of + {unknown, VsnString} -> + VsnString; + Cmd -> + {ok, VsnString} = rebar_utils:sh(Cmd, [{use_stdout, false}]), + string:strip(VsnString, right, $\n) + end. vcs_vsn_cmd(git) -> "git describe --always --tags"; -vcs_vsn_cmd(hg) -> "hg identify -i"; +vcs_vsn_cmd(hg) -> "hg identify -i"; vcs_vsn_cmd(bzr) -> "bzr revno"; -vcs_vsn_cmd(svn) -> "svnversion". +vcs_vsn_cmd(svn) -> "svnversion"; +vcs_vsn_cmd(Version) -> {unknown, Version}. |