This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content

Improve branch handling of filehooks

We are using the convention that the branch to be indexed is the master branch. Some of our code assumes that this branch is the default branch. This has two problems:

  • If someone sets their default branch to something other than the branch they would like to be indexed, we might index the wrong branch or even try to access master in some cases but the default branch in others. This might cause our code to break.

  • Some people do not want to use a branch called master. GitLab will call the default branch for repositories it creates main starting with version 14.0 (See https://docs.gitlab.com/ee/user/project/repository/branches/default.html)

We should ensure that we index one branch and one branch only and do so consistently. I suggest we take care to always explicitly specify which branch we want to access in our code and update our convention for users. One potential approach could be trying to index main, falling back to master if this branch does not exist and giving the user an error if their project has neither of these branches.