Allow force commit via API to override existing branch
Description
The background for this request can be found from this note onwards: https://gitlab.com/gitlab-org/gitlab-ce/issues/37775#note_63049903
In short, I would like to have a way to "force push" to a branch using the API.
Proposal
Extend the POST /projects/:id/repository/commits
endpoint to allow an option "force"
which when set to true allows the commit in the POST
to "force push" over the top of any existing branch commits, if found.
e.g. let's say we have base branch master
and a feature branch feature-a
with a modified package.json
. We should be allowed to submit a POST
that sets branch=feature-a
, start_branch=master
and any content we wish (e.g. a different update to package.json
, or updates to README.md
, or a new file).
Currently if branch
exists then the request is rejected, which is a sensible default. I propose that in the case where force=true
is specified, the old branch content are replaced. i.e. the commit is added to start_branch
and then the branch
ref is created or updated to point to that new commit.
Links / references
This is for use with the app Renovate: https://github.com/renovateapp/renovate, which is used by quite a few GitLab users.