     :branch_name,
     :target_branch,
     :latest_commit,
-    state: :discussing
+    state: :under_review
   ]
 
   @doc """

  @type sha :: String.t

  @typedoc "Supported merge request states"
  @type state :: :discussing | :approved | :pending | :passed | :failed | :error

  @type t ::
    %MergeRequest{


  # A basic Finite State Machine

  def approve(%MergeRequest{state: :under_review} = req),
    do: %{req | state: :approved}

  def unapprove(%MergeRequest{} = req),
    do: %{req | state: :under_review}

  def merge_passed(%MergeRequest{state: :approved} = req),
    do: %{req | state: :build_pending}

  def merge_failed(%MergeRequest{state: :approved} = req),
    do: %{req | state: :error}

  def build_passed(%MergeRequest{state: :build_pending} = req),
    do: %{req | state: :build_passed}

  def build_failed(%MergeRequest{state: :build_pending} = req),
    do: %{req | state: :build_failed}

  def build_error(%MergeRequest{state: :build_pending} = req),
    do: %{req | state: :error}

  def ffwd_failed(%MergeRequest{state: :build_passed} = req),
    do: %{req | state: :error}
end

