summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md94
-rw-r--r--README.md72
-rw-r--r--src/rebar_ct.erl2
-rw-r--r--src/rebar_erlc_compiler.erl10
-rw-r--r--src/rebar_erlydtl_compiler.erl32
-rw-r--r--src/rebar_eunit.erl12
-rw-r--r--src/rebar_neotoma_compiler.erl8
-rw-r--r--src/rebar_templater.erl21
-rw-r--r--src/rebar_upgrade.erl22
9 files changed, 167 insertions, 106 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..30693d8
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,94 @@
+Contributing to rebar
+---------------------
+
+Before implementing a new feature, please submit a ticket to discuss your plans.
+The feature might have been rejected already, or the implementation might already be decided.
+
+See [Community and Resources](README.md#community-and-resources).
+
+Code style
+----------
+
+The following rules must be followed:
+ * Do not introduce trailing whitespace
+ * Do not mix spaces and tabs
+ * Do not introduce lines longer than 80 characters
+
+The following rules should be followed:
+ * Write small functions whenever possible
+ * Avoid having too many clauses containing clauses containing clauses.
+ Basically, avoid deeply nested functions.
+
+[erlang-mode (emacs)](http://www.erlang.org/doc/man/erlang.el.html)
+indentation is preferred. This will keep the code base consistent.
+vi users are encouraged to give [Vim emulation](http://emacswiki.org/emacs/Evil) ([more
+info](https://gitorious.org/evil/pages/Home)) a try.
+
+Pull requests and branching
+---------------------------
+
+Use one topic branch per pull request. If you do that, you can add extra commits or fix up
+buggy commits via `git rebase -i`, and update the branch. The updated branch will be
+visible in the same pull request. Therefore, you should not open a new pull request when
+you have to fix your changes.
+
+Do not commit to master in your fork.
+
+Provide a clean branch without merge commits.
+
+Committing your changes
+-----------------------
+
+Please ensure that all commits pass all tests, and do not have extra Dialyzer warnings.
+To do that run `make check`. If you didn't build via `make debug` at first, the beam files in
+`ebin/` might be missing debug_info required for [xref](http://www.erlang.org/doc/man/xref.html)
+and [Dialyzer](http://www.erlang.org/doc/man/dialyzer.html), causing a test
+failure.
+If that happens, running `make clean` before running `make check` could solve the problem.
+If you change any of the files with known but safe to ignore Dialyzer warnings, you may
+have to adapt the line number(s) in [dialyzer_reference](dialyzer_reference). If you do that,
+do not remove the
+leading blank line.
+
+#### Structuring your commits
+
+Fixing a bug is one commit.
+Adding a feature is one commit.
+Adding two features is two commits.
+Two unrelated changes is two commits.
+
+If you fix a (buggy) commit, squash (`git rebase -i`) the changes as a fixup commit into
+the original commit.
+
+#### Writing Commit Messages
+
+It's important to write a proper commit title and description. The commit title must be
+at most 50 characters; it is the first line of the commit text. The second line of the
+commit text must be left blank. The third line and beyond is the commit message. You
+should write a commit message. If you do, wrap all lines at 72 characters. You should
+explain what the commit does, what references you used, and any other information
+that helps understanding your changes.
+
+Basically, structure your commit message like this:
+
+<pre>
+One line summary (at most 50 characters)
+
+Longer description (wrap at 72 characters)
+</pre>
+
+##### Commit title/summary
+
+* At most 50 characters
+* What was changed
+* Imperative present tense (Fix, Add, Change)
+ * `Fix bug 123`
+ * `Add 'foobar' command`
+ * `Change default timeout to 123`
+* No period
+
+##### Commit description
+
+* Wrap at 72 characters
+* Why, explain intention and implementation approach
+* Present tense
diff --git a/README.md b/README.md
index 3be5091..3ec4a3a 100644
--- a/README.md
+++ b/README.md
@@ -51,77 +51,7 @@ and you can use rebar to build OTP-compliant apps.
Contributing to rebar
=====================
-Pull requests and branching
----------------------------
-
-Use one topic branch per pull request.
-
-Do not commit to master in your fork.
-
-Provide a clean branch without any merge commits from upstream.
-
-Usually you should squash any intermediate commits into the original single commit.
-
-Code style
-----------
-
-Do not introduce trailing whitespace.
-
-Do not mix spaces and tabs.
-
-Do not introduce lines longer than 80 characters.
-
-[erlang-mode (emacs)](http://www.erlang.org/doc/man/erlang.el.html) indentation
-is preferred. vi-only users are encouraged to give [Vim
-emulation](http://emacswiki.org/emacs/Evil) ([more
-info](https://gitorious.org/evil/pages/Home)) a try.
-
-Writing Commit Messages
------------------------
-
-Structure your commit message like this:
-
-<pre>
-One line summary (less than 50 characters)
-
-Longer description (wrap at 72 characters)
-</pre>
-
-### Summary
-
-* Less than 50 characters
-* What was changed
-* Imperative present tense (fix, add, change)
- * `Fix bug 123`
- * `Add 'foobar' command`
- * `Change default timeout to 123`
-* No period
-
-### Description
-
-* Wrap at 72 characters
-* Why, explain intention and implementation approach
-* Present tense
-
-### Atomicity
-
-* Break up logical changes
-* Make whitespace changes separately
-
-Run checks
-----------
-
-Before you submit a patch, run ``make check`` to execute the test suite and
-check for [xref](http://www.erlang.org/doc/man/xref.html) and
-[Dialyzer](http://www.erlang.org/doc/man/dialyzer.html) warnings. You may have
-to run ``make clean`` first.
-
-[Dialyzer](http://www.erlang.org/doc/man/dialyzer.html) warnings are compared
-against a set of safe-to-ignore warnings found in
-[dialyzer_reference](https://raw.github.com/rebar/rebar/master/dialyzer_reference).
-[xref](http://www.erlang.org/doc/man/xref.html) is run with [custom
-queries](https://raw.github.com/rebar/rebar/master/rebar.config) to suppress
-safe-to-ignore warnings.
+Please refer to [CONTRIBUTING](CONTRIBUTING.md).
Community and Resources
-----------------------
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl
index 04b2a51..74ae618 100644
--- a/src/rebar_ct.erl
+++ b/src/rebar_ct.erl
@@ -149,7 +149,7 @@ check_fail_log(Config, RawLog, Command, Result) ->
check_log(Config,RawLog,Fun) ->
{ok, Msg} =
- rebar_utils:sh("grep -e 'TEST COMPLETE' -e '{error,make_failed}' "
+ rebar_utils:sh("grep -e \"TEST COMPLETE\" -e \"{error,make_failed}\" "
++ RawLog, [{use_stdout, false}]),
MakeFailed = string:str(Msg, "{error,make_failed}") =/= 0,
RunFailed = string:str(Msg, ", 0 failed") =:= 0,
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index caef0d2..4157ba4 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -34,6 +34,7 @@
info/2]).
-include("rebar.hrl").
+-include_lib("stdlib/include/erl_compile.hrl").
%% ===================================================================
%% Public API
@@ -401,7 +402,14 @@ compile_mib(Source, Target, Config) ->
case snmpc:compile(Source, Opts) of
{ok, _} ->
Mib = filename:rootname(Target),
- ok = snmpc:mib_to_hrl(Mib),
+ MibToHrlOpts =
+ case proplists:get_value(verbosity, Opts, undefined) of
+ undefined ->
+ #options{specific = []};
+ Verbosity ->
+ #options{specific = [{verbosity, Verbosity}]}
+ end,
+ ok = snmpc:mib_to_hrl(Mib, Mib, MibToHrlOpts),
Hrl_filename = Mib ++ ".hrl",
rebar_file_utils:mv(Hrl_filename, "include"),
ok;
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 4449be6..6172879 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -116,8 +116,8 @@ compile(Config, _AppFile) ->
option(source_ext, DtlOpts),
option(out_dir, DtlOpts),
option(module_ext, DtlOpts) ++ ".beam",
- fun(S, T, _C) ->
- compile_dtl(S, T, DtlOpts)
+ fun(S, T, C) ->
+ compile_dtl(C, S, T, DtlOpts)
end,
[{check_last_mod, false},
{recursive, option(recursive, DtlOpts)}])
@@ -169,10 +169,10 @@ default(out_dir) -> "ebin";
default(source_ext) -> ".dtl";
default(module_ext) -> "_dtl";
default(custom_tags_dir) -> "";
-default(compiler_options) -> [report, return];
+default(compiler_options) -> [return];
default(recursive) -> true.
-compile_dtl(Source, Target, DtlOpts) ->
+compile_dtl(Config, Source, Target, DtlOpts) ->
case code:which(erlydtl) of
non_existing ->
?ERROR("~n===============================================~n"
@@ -185,13 +185,13 @@ compile_dtl(Source, Target, DtlOpts) ->
_ ->
case needs_compile(Source, Target, DtlOpts) of
true ->
- do_compile(Source, Target, DtlOpts);
+ do_compile(Config, Source, Target, DtlOpts);
false ->
skipped
end
end.
-do_compile(Source, Target, DtlOpts) ->
+do_compile(Config, Source, Target, DtlOpts) ->
%% TODO: Check last mod on target and referenced DTLs here..
%% ensure that doc_root and out_dir are defined,
@@ -208,19 +208,17 @@ do_compile(Source, Target, DtlOpts) ->
case erlydtl:compile(Source,
module_name(Target),
Opts) of
- ok -> ok;
- {error, {File, [{Pos, _Mod, Err}]}} ->
- ?ERROR("Compiling template ~p failed:~n (~s): ~p~n",
- [File, err_location(Pos), Err]);
- Reason ->
- ?ERROR("Compiling template ~s failed:~n ~p~n",
- [Source, Reason]),
- ?FAIL
+ ok ->
+ ok;
+ error ->
+ rebar_base_compiler:error_tuple(Config, Source, [], [], Opts);
+ {error, {_File, _Msgs} = Error} ->
+ rebar_base_compiler:error_tuple(Config, Source, [Error], [], Opts);
+ {error, Msg} ->
+ Es = [{Source, [{erlydtl_parser, Msg}]}],
+ rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts)
end.
-err_location({L,C}) -> io_lib:format("line:~w, col:~w", [L, C]);
-err_location(L) -> io_lib:format("line:~w", [L]).
-
module_name(Target) ->
F = filename:basename(Target),
string:substr(F, 1, length(F)-length(".beam")).
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index 95ba3e8..d39b1a2 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -802,11 +802,11 @@ pause_until_net_kernel_stopped() ->
pause_until_net_kernel_stopped(0) ->
exit(net_kernel_stop_failed);
pause_until_net_kernel_stopped(N) ->
- try
- timer:sleep(100),
- pause_until_net_kernel_stopped(N - 1)
- catch
- error:badarg ->
+ case node() of
+ 'nonode@nohost' ->
?DEBUG("Stopped net kernel.\n", []),
- ok
+ ok;
+ _ ->
+ timer:sleep(100),
+ pause_until_net_kernel_stopped(N - 1)
end.
diff --git a/src/rebar_neotoma_compiler.erl b/src/rebar_neotoma_compiler.erl
index b9f23f2..5549dc4 100644
--- a/src/rebar_neotoma_compiler.erl
+++ b/src/rebar_neotoma_compiler.erl
@@ -70,10 +70,10 @@ info(help, compile) ->
"Valid rebar.config options:~n"
" ~p~n",
[
- {neotom_opts, [{doc_root, "src"},
- {out_dir, "src"},
- {source_ext, ".peg"},
- {module_ext, ""}]}
+ {neotoma_opts, [{doc_root, "src"},
+ {out_dir, "src"},
+ {source_ext, ".peg"},
+ {module_ext, ""}]}
]).
neotoma_opts(Config) ->
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index e997975..b8f7087 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -347,6 +347,10 @@ write_file(Output, Data, Force) ->
{error, exists}
end.
+prepend_instructions(Instructions, Rest) when is_list(Instructions) ->
+ Instructions ++ Rest;
+prepend_instructions(Instruction, Rest) ->
+ [Instruction|Rest].
%%
%% Execute each instruction in a template definition file.
@@ -364,6 +368,23 @@ execute_template(_Files, [], _TemplateType, _TemplateName,
?ERROR("One or more files already exist on disk and "
"were not generated:~n~s~s", [Msg , Help])
end;
+execute_template(Files, [{'if', Cond, True} | Rest], TemplateType,
+ TemplateName, Context, Force, ExistingFiles) ->
+ execute_template(Files, [{'if', Cond, True, []}|Rest], TemplateType,
+ TemplateName, Context, Force, ExistingFiles);
+execute_template(Files, [{'if', Cond, True, False} | Rest], TemplateType,
+ TemplateName, Context, Force, ExistingFiles) ->
+ Instructions = case dict:find(Cond, Context) of
+ {ok, true} ->
+ True;
+ {ok, "true"} ->
+ True;
+ _ ->
+ False
+ end,
+ execute_template(Files, prepend_instructions(Instructions, Rest),
+ TemplateType, TemplateName, Context, Force,
+ ExistingFiles);
execute_template(Files, [{template, Input, Output} | Rest], TemplateType,
TemplateName, Context, Force, ExistingFiles) ->
InputName = filename:join(filename:dirname(TemplateName), Input),
diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl
index d18603c..1441c5a 100644
--- a/src/rebar_upgrade.erl
+++ b/src/rebar_upgrade.erl
@@ -184,13 +184,23 @@ boot_files(TargetDir, Ver, Name) ->
filename:join([TargetDir, "releases", Ver, "start_clean.boot"]),
filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])),
- {ok, _} = file:copy(
- filename:join([TargetDir, "releases", Ver, "sys.config"]),
- filename:join([".", ?TMP, "releases", Ver, "sys.config"])),
+ SysConfig = filename:join([TargetDir, "releases", Ver, "sys.config"]),
+ case filelib:is_regular(SysConfig) of
+ true ->
+ {ok, _} = file:copy(
+ SysConfig,
+ filename:join([".", ?TMP, "releases", Ver, "sys.config"]));
+ false -> ok
+ end,
- {ok, _} = file:copy(
- filename:join([TargetDir, "releases", Ver, "vm.args"]),
- filename:join([".", ?TMP, "releases", Ver, "vm.args"])).
+ VmArgs = filename:join([TargetDir, "releases", Ver, "vm.args"]),
+ case filelib:is_regular(VmArgs) of
+ true ->
+ {ok, _} = file:copy(
+ VmArgs,
+ filename:join([".", ?TMP, "releases", Ver, "vm.args"]));
+ false -> {ok, 0}
+ end.
make_tar(NameVer, NewVer, NewName) ->
Filename = NameVer ++ ".tar.gz",