add Geef.Revwalk module for Elixir
This commit is contained in:
committed by
Carlos Martín Nieto
parent
01254f2f90
commit
79f89bcd41
@@ -159,6 +159,9 @@ revwalk_next(_Walk) ->
|
||||
revwalk_sorting(_Walk, _Sort) ->
|
||||
?NIF_FN.
|
||||
|
||||
revwalk_simplify_first_parent(_Walk) ->
|
||||
?NIF_FN.
|
||||
|
||||
revwalk_reset(_Walk) ->
|
||||
?NIF_FN.
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
%% API
|
||||
-export([open/1, init/2, path/1, workdir/1, odb/1, is_bare/1, references/1, discover/1,
|
||||
lookup_object/2, revwalk/1, stop/1,
|
||||
reference_dwim/2, handle/1, iterator/2]).
|
||||
lookup_object/2, revwalk/1, stop/1,
|
||||
reference_dwim/2, handle/1, iterator/2]).
|
||||
-export([reference_has_log/2]).
|
||||
-export([reference_resolve/2]).
|
||||
-export([reflog_read/2, reflog_delete/2]).
|
||||
@@ -37,21 +37,21 @@ discover(Path) ->
|
||||
-spec open(iolist()) -> {ok, pid()} | {error, term()}.
|
||||
open(Path) ->
|
||||
case geef_nif:repository_open(Path) of
|
||||
{ok, Handle} ->
|
||||
start_link(Handle);
|
||||
Other ->
|
||||
Other
|
||||
{ok, Handle} ->
|
||||
start_link(Handle);
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
|
||||
%% @doc Initialize a new repository
|
||||
-spec init(iolist(), boolean()) -> {ok, pid()} | {error, term()}.
|
||||
init(Path, Bare) ->
|
||||
case geef_nif:repository_init(Path, Bare) of
|
||||
{ok, Handle} ->
|
||||
start_link(Handle);
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
{ok, Handle} ->
|
||||
start_link(Handle);
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
|
||||
%% @doc The repository's git-dir path
|
||||
-spec path(pid()) -> binary().
|
||||
@@ -224,18 +224,18 @@ start_link(Handle) ->
|
||||
|
||||
handle_odb(Handle) ->
|
||||
case geef_nif:repository_get_odb(Handle) of
|
||||
{ok, OdbHandle} ->
|
||||
geef_odb:start_link(OdbHandle);
|
||||
Other ->
|
||||
Other
|
||||
{ok, OdbHandle} ->
|
||||
geef_odb:start_link(OdbHandle);
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
|
||||
handle_revwalk(Handle) ->
|
||||
case geef_nif:revwalk_new(Handle) of
|
||||
{ok, WalkHandle} ->
|
||||
geef_revwalk:start_link(WalkHandle);
|
||||
Error ->
|
||||
Error
|
||||
{ok, WalkHandle} ->
|
||||
geef_revwalk:start_link(WalkHandle);
|
||||
Error ->
|
||||
Error
|
||||
end.
|
||||
|
||||
handle_config(Handle) ->
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
%% API
|
||||
-export([start_link/1]).
|
||||
-export([push/2, hide/2, next/1, sorting/2, stop/1]).
|
||||
-export([push/2, hide/2, next/1, sorting/2, simplify_first_parent/1, reset/1, stop/1]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-record(state, {handle}).
|
||||
-include("geef_records.hrl").
|
||||
@@ -46,7 +46,16 @@ sorting(Pid, Opts) when is_list(Opts) ->
|
||||
sorting(Pid, Opt) when is_atom(Opt) ->
|
||||
gen_server:call(Pid, {sort, [Opt]}).
|
||||
|
||||
-spec simplify_first_parent(pid) -> ok.
|
||||
simplify_first_parent(Pid) ->
|
||||
gen_server:call(Pid, simplify_first_parent).
|
||||
|
||||
-spec reset(pid) -> ok.
|
||||
reset(Pid) ->
|
||||
gen_server:call(Pid, reset).
|
||||
|
||||
%% @doc Next commit in the walk
|
||||
-spec next(pid) -> {ok, geef_oid:oid()} | {error, iterover}.
|
||||
next(Pid) ->
|
||||
gen_server:call(Pid, next).
|
||||
|
||||
@@ -76,12 +85,18 @@ init(Handle) ->
|
||||
handle_call({sort, Opts}, _From, State = #state{handle=Handle}) ->
|
||||
geef_nif:revwalk_sorting(Handle, Opts),
|
||||
{reply, ok, State};
|
||||
handle_call(simplify_first_parent, _From, State = #state{handle=Handle}) ->
|
||||
geef_nif:revwalk_simplify_first_parent(Handle),
|
||||
{reply, ok, State};
|
||||
handle_call({push, Oid}, _From, State = #state{handle=Handle}) ->
|
||||
Reply = geef_nif:revwalk_push(Handle, Oid, false),
|
||||
{reply, Reply, State};
|
||||
handle_call({hide, Oid}, _From, State = #state{handle=Handle}) ->
|
||||
Reply = geef_nif:revwalk_push(Handle, Oid, true),
|
||||
{reply, Reply, State};
|
||||
handle_call(reset, _From, State = #state{handle=Handle}) ->
|
||||
geef_nif:revwalk_reset(Handle),
|
||||
{reply, ok, State};
|
||||
handle_call(next, _From, State = #state{handle=Handle}) ->
|
||||
Reply = geef_nif:revwalk_next(Handle),
|
||||
{reply, Reply, State};
|
||||
|
||||
Reference in New Issue
Block a user