Branch merge API for TerminusDB.
Wraps the /api/rebase endpoint to merge (rebase) a source branch into a target
branch. TerminusDB uses a rebase model: the source branch's commits are
replayed on top of the target branch, creating a linear history.
Quick start
config =
TerminusDB.Config.new(endpoint: "http://localhost:6363")
|> TerminusDB.Config.with_database("mydb")
# Merge `feature` into `main`
{:ok, result} = TerminusDB.Merge.merge(config,
source_branch: "feature",
target_branch: "main"
)
Summary
Functions
Merges (rebases) the source_branch into the target_branch.
Merges branches, or raises TerminusDB.Error.
Types
Functions
@spec merge(TerminusDB.Config.t(), [merge_opt()]) :: {:ok, map()} | {:error, TerminusDB.Error.t()}
Merges (rebases) the source_branch into the target_branch.
TerminusDB replays the source branch's commits on top of the target branch. If there are conflicts, the operation returns an error describing them.
Options
:source_branch(required) - the branch to merge from.:target_branch- the branch to merge into (default:config.branch).:organization- overridesconfig.organization.:repo- overridesconfig.repo.:author- commit author for the merge commit.:message- commit message for the merge commit.
Examples
iex> config = TerminusDB.Config.new(
...> endpoint: "http://localhost:6363",
...> adapter: fn req -> {req, Req.Response.new(status: 200, body: %{"api:status" => "api:success"})} end
...> ) |> TerminusDB.Config.with_database("mydb")
iex> {:ok, result} = TerminusDB.Merge.merge(config,
...> source_branch: "feature",
...> target_branch: "main"
...> )
iex> result["api:status"]
"api:success"
@spec merge!(TerminusDB.Config.t(), [merge_opt()]) :: map()
Merges branches, or raises TerminusDB.Error.
Examples
iex> config = TerminusDB.Config.new(
...> endpoint: "http://localhost:6363",
...> adapter: fn req -> {req, Req.Response.new(status: 200, body: %{"api:status" => "api:success"})} end
...> ) |> TerminusDB.Config.with_database("mydb")
iex> TerminusDB.Merge.merge!(config, source_branch: "feature", target_branch: "main")
%{"api:status" => "api:success"}