Skip to main content

src/version_bump@context.erl

-module(version_bump@context).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/version_bump/context.gleam").
-export([new/5]).
-export_type([context/0]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

?MODULEDOC(
    " The shared context threaded through every plugin hook, mirroring\n"
    " semantic-release's `context` object. It is immutable: the engine produces a\n"
    " new `Context` as the pipeline advances (e.g. after analysing commits it sets\n"
    " `next_release`).\n"
).

-type context() :: {context,
        binary(),
        gleam@dict:dict(binary(), binary()),
        version_bump@config:config(),
        version_bump@branch:branch(),
        list(version_bump@branch:branch()),
        list(version_bump@commit_parser:conventional_commit()),
        gleam@option:option(version_bump@release:last_release()),
        gleam@option:option(version_bump@release:next_release()),
        list(version_bump@release:release()),
        list(binary()),
        boolean()}.

-file("src/version_bump/context.gleam", 30).
?DOC(" Build an initial context with the empty/None fields the pipeline fills in.\n").
-spec new(
    binary(),
    gleam@dict:dict(binary(), binary()),
    version_bump@config:config(),
    version_bump@branch:branch(),
    list(version_bump@branch:branch())
) -> context().
new(Cwd, Env, Config, Branch, Branches) ->
    {context,
        Cwd,
        Env,
        Config,
        Branch,
        Branches,
        [],
        none,
        none,
        [],
        [],
        erlang:element(6, Config)}.