From 3e68bb2f61981fab687795c0a069fec143454e1e Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Sat, 7 Oct 2023 17:53:12 +0200 Subject: [PATCH] Add 'branch' option --- src/edown_doclet.erl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/edown_doclet.erl b/src/edown_doclet.erl index 8c9c3d5..baaf902 100644 --- a/src/edown_doclet.erl +++ b/src/edown_doclet.erl @@ -155,7 +155,7 @@ make_top_level_README(Data, Options) -> Dir = filename:dirname(Path), Filename = filename:basename(Path), make_top_level_README(Data, Dir, Filename, BaseHRef, - get_git_branch(), Options); + get_branch(Options), Options); {Path, BaseHRef, Branch} -> Dir = filename:dirname(Path), Filename = filename:basename(Path), @@ -165,10 +165,6 @@ make_top_level_README(Data, Options) -> target(Options) -> proplists:get_value(edown_target, Options, github). -%% make_top_level_README(Data, Dir, F, BaseHRef) -> -%% Branch = get_git_branch(), -%% make_top_level_README(Data, Dir, F, BaseHRef, Branch). - make_top_level_README(Data, Dir, F, BaseHRef, Branch, Options) -> Target = target(Options), Exp = [xmerl_lib:expand_element(D) || D <- Data], @@ -229,6 +225,14 @@ do_redirect(Href, Prefix, Args) -> Prefix ++ Href ++ Args end. +get_branch(Options) -> + case proplists:get_value(branch, Options) of + undefined -> + get_git_branch(); + Branch -> + Branch + end. + get_git_branch() -> case os:cmd("git rev-parse --abbrev-ref HEAD") of "fatal:" ++ _ -> "master"; % sensible default