# shellcheck shell=bash disable=SC2034,SC2154 disable=SC2154

# Section: create & default
# https://gitea.com/api/swagger#/repository/repoCreateBranch
___x_cmd_fjo_repo_branch_create(){
    param:scope     ___x_cmd_fjo
    param:dsl       '
options:
    --repo|-r             "<owner_path>/<repo_path>"                                          <>:RepoName
    --branch              "branch name"                                                       <>
    --old_ref_name        "Name of the old branch/tag/commit to create from"                  <>=""
    --json|-j             "output json data"
'
    param:run

    ___x_cmd_fjo_param_init_owner_repo

    local gen_fjo_json
    gen_fjo_json="$(param:option2json -repo -branch ${branch+"new_branch_name=branch"} )"
    ___x_cmd_fjo_curl post "/repos/${owner_repo}/branches" "gen_fjo_json" | ___x_cmd_fjo_branch_____ui_handler Creating
}
