From 46b2c0612e893a5bf34ec720810a9bd52928fd63 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 7 Jan 2011 12:40:02 +0100 Subject: Fix bug 770 --- src/rebar_app_utils.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 9574775..ea8e079 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -80,7 +80,7 @@ app_name(AppFile) -> app_applications(AppFile) -> case load_app_file(AppFile) of {ok, _, AppInfo} -> - proplists:get_value(applications, AppInfo); + get_value(applications, AppInfo, AppFile); {error, Reason} -> ?ABORT("Failed to extract applications from ~s: ~p\n", [AppFile, Reason]) @@ -89,7 +89,7 @@ app_applications(AppFile) -> app_vsn(AppFile) -> case load_app_file(AppFile) of {ok, _, AppInfo} -> - proplists:get_value(vsn, AppInfo); + get_value(vsn, AppInfo, AppFile); {error, Reason} -> ?ABORT("Failed to extract vsn from ~s: ~p\n", [AppFile, Reason]) @@ -116,3 +116,11 @@ load_app_file(Filename) -> {AppName, AppData} -> {ok, AppName, AppData} end. + +get_value(Key, AppInfo, AppFile) -> + case proplists:get_value(Key, AppInfo) of + undefined -> + ?ABORT("Failed to get app value '~p' from '~s'~n", [Key, AppFile]); + Value -> + Value + end. -- cgit v1.1 From c466076ffb5a1ea4c00d49fefff0dcfbceb58236 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 31 Jan 2011 17:43:31 +0100 Subject: Clean up emacs file local variables --- src/rebar_app_utils.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index ea8e079..1fa870b 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -1,4 +1,4 @@ -%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 et %% ------------------------------------------------------------------- %% -- cgit v1.1 From b0860da1241e482e5125714e1cd343c9d734db10 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 2 Dec 2010 17:12:54 -0500 Subject: Expand {vsn,git} in app.src to git-describe output --- src/rebar_app_utils.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 1fa870b..34d357a 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -89,7 +89,14 @@ app_applications(AppFile) -> app_vsn(AppFile) -> case load_app_file(AppFile) of {ok, _, AppInfo} -> - get_value(vsn, AppInfo, AppFile); + case get_value(vsn, AppInfo, AppFile) of + git -> + Cmd = "git describe --tags --always", + {ok, VsnString} = rebar_utils:sh(Cmd, []), + string:strip(VsnString, right, $\n); + Version -> + Version + end; {error, Reason} -> ?ABORT("Failed to extract vsn from ~s: ~p\n", [AppFile, Reason]) -- cgit v1.1 From 01a7473dac44befe05c460e28c601e2eec785b41 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Wed, 16 Feb 2011 23:47:23 +0100 Subject: Add {vsn,Vcs} support for bzr, hg and svn --- src/rebar_app_utils.erl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 34d357a..f50ac86 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -90,12 +90,11 @@ app_vsn(AppFile) -> case load_app_file(AppFile) of {ok, _, AppInfo} -> case get_value(vsn, AppInfo, AppFile) of - git -> - Cmd = "git describe --tags --always", - {ok, VsnString} = rebar_utils:sh(Cmd, []), - string:strip(VsnString, right, $\n); - Version -> - Version + git -> vcs_vsn(git); + hg -> vcs_vsn(hg); + bzr -> vcs_vsn(bzr); + svn -> vcs_vsn(svn); + Version -> Version end; {error, Reason} -> ?ABORT("Failed to extract vsn from ~s: ~p\n", @@ -131,3 +130,13 @@ get_value(Key, AppInfo, AppFile) -> Value -> Value end. + +vcs_vsn(Vcs) -> + Cmd = vcs_vsn_cmd(Vcs), + {ok, VsnString} = rebar_utils:sh(Cmd, [{use_stdout, false}]), + string:strip(VsnString, right, $\n). + +vcs_vsn_cmd(git) -> "git describe --always --tags"; +vcs_vsn_cmd(hg) -> "hg identify -i"; +vcs_vsn_cmd(bzr) -> "bzr revno"; +vcs_vsn_cmd(svn) -> "svnversion". -- cgit v1.1 From 6056c63eed288736c912c82d6f36aa7dd055f9ca Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 18 Feb 2011 10:59:57 +0100 Subject: Clean up and simplify {vsn, VCS} support --- src/rebar_app_utils.erl | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/rebar_app_utils.erl') 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}. -- cgit v1.1