Enables branch protection for one or more branches in the given GitLab project (repo) to prevents deleting the branch or force pushing over it
If no branch is specified, the applies branches protections to any of the following branches if they're found:
$default_branches_to_protect
Project can be the full project name (eg. HariSekhon/DevOps-Bash-tools) or the project ID
Project username prefix can be omitted, will use \$GITLAB_USER if available, otherwise will query the GitLab API to determine the user owning the \$GITLAB_TOKEN
Automatically url encodes the project name and description for you since the GitLab API will return404 and fail to find the project name if not url encoded
Uses the adajcent script gitlab_api.sh, see there for authentication details
\$CURL_OPTS can be set to provide extra arguments to curl
# XXX: GitLab API ignores PATCH'ing allow_force_push, only works for code_owner_approval_required - the only way to enforce allow_force_push=false is to remove and recreate the branch protection
"$srcdir/gitlab_api.sh""/projects/$project/protected_branches?name=$branch&allow_force_push=$allow_force_push&code_owner_approval_required=$code_owner_approval_required" -X POST >/dev/null