Skip to content

Avoid branch name checking when creating a new snippet

What does this MR do?

In #273411 (closed) we discovered there can be a concurrency problem in the time window between when we create the snippet and when the git hook is called and we perform the SnippetCheck to check branches.

When we create or update a snippet we explicitly specify the branch to perform the commits to, this branch is snippet.default_branch. When the git hook is accepted and SnippetCheck is called, we also retrieved snippet.default_branch to ensure that the branch the user used in the commit was the default one. Nevertheless, in the time window between the commit operation starts and the check is called, the instance default branch can change and, therefore, a valid commit operation becomes invalid.

There is a deeper explanation in #273411 (comment 458686199)

In this MR we change that. Since BE controls the first branch (and default one) the snippet is going to get, and not the users, we're going to allow it. Once it gets created, users can't change it or create new ones.

Does this MR meet the acceptance criteria?

Conformity

Related to #273411 (closed)

Edited by Francisco Javier López

Merge request reports

Loading