# shellcheck shell=bash disable=SC2034,SC2154 disable=SC2154
# https://gitea.com/api/swagger#/repository/repoListBranchProtection
___x_cmd_fjo_repo_branch_protection_info(){
    param:dsl       '
options:
    #1          "branch name"                  <>
    --repo|-r      "repo name"                 <>:RepoName
    --json|-j   "output json data"
'
    param:run

    ___x_cmd_fjo_param_init_owner_repo
    ___x_cmd_fjo_curl get "/repos/${owner_repo}/branch_protections/${1}" | (
        if [ -n "$ENFORCE_JSON" ] || [ -n "$json" ]; then
            ___x_cmd_cmds_cat
            ___x_cmd_fjo_http_error
            return
        fi

        x jo env . name=.branch_name  \
        enablePush=.enable_push pushWhitelist=.push_whitelist_usernames \
        pushWhitelistTeams=.push_whitelist_teams fjo_resp_err=.message
        if [ -n "$name" ]; then
            ___x_cmd_ui_tf true "protection branch $1 info" "enablePush:$enablePush" \
                "pushWhitelist:$pushWhitelist" "pushWhitelistTeams:$pushWhitelistTeams"
        else
            ___x_cmd_ui_tf false "protection branch $1 info failed"
            ___x_cmd_fjo____handle_resp
            return 1
        fi
    )
}