From cc8124a6b9daa493b7bf415e120ad11ab65e3685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sun, 12 May 2013 15:02:54 +0200 Subject: [PATCH] Accept an iolist in the revwalk --- src/geef_revwalk.erl | 12 ++++++++++-- test/revwalk_test.erl | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/geef_revwalk.erl b/src/geef_revwalk.erl index 0ff0f5d..9c0d2cc 100644 --- a/src/geef_revwalk.erl +++ b/src/geef_revwalk.erl @@ -28,16 +28,24 @@ %% @doc Push a commit. This commit and its parents will be included in %% the walk as long as they haven't been hidden. At least one commit %% must be pushed before starting a walk. --spec push(pid(), oid()) -> ok | {error, binary()}. +-spec push(pid(), oid() | iolist()) -> ok | {error, binary()}. push(Pid, #oid{oid=Oid}) -> + gen_server:call(Pid, {push, Oid}); +push(Pid, Id) -> + #oid{oid=Oid} = geef_oid:parse(Id), gen_server:call(Pid, {push, Oid}). + %% @doc Hide a commit. Hide a commit and its parents. Any Parent of %% this commit won't be included in the walk. --spec hide(pid(), oid()) -> ok | {error, binary()}. +-spec hide(pid(), oid() | iolist()) -> ok | {error, binary()}. hide(Pid, #oid{oid=Oid}) -> + gen_server:call(Pid, {hide, Oid}); +hide(Pid, Id) -> + #oid{oid=Oid} = geef_oid:parse(Id), gen_server:call(Pid, {hide, Oid}). + %% @doc Select the sorting method -spec sorting(pid, atom() | [atom()]) -> ok. sorting(Pid, Opts) when is_list(Opts) -> diff --git a/test/revwalk_test.erl b/test/revwalk_test.erl index 79334ac..3f79664 100644 --- a/test/revwalk_test.erl +++ b/test/revwalk_test.erl @@ -26,8 +26,7 @@ count_walk(Walk, Acc) -> amount_test(Repo) -> {ok, Walk} = geef_repo:revwalk(Repo), - Id = geef_oid:parse("a4a7dce85cf63874e984719f4fdd239f5145052f"), - ok = geef_revwalk:push(Walk, Id), + ok = geef_revwalk:push(Walk, "a4a7dce85cf63874e984719f4fdd239f5145052f"), Count = count_walk(Walk, 0), geef_revwalk:stop(Walk), [?_assertEqual(6, Count)].