2

This problem occurs on a self-hosted instance of GitLab Enterprise Edition (v14.7.2ee). All projects are set to "Internal".

Steps to reproduce:

  1. List all branches using the API
  2. Create a new branch using the API
  3. List all branches using the API

The new branch created in step 2 is missing unless we put a delay of about 30 seconds between step 2 and step 3.

However, if we do this instead:

  1. Create a new branch using the API
  2. List all branches using the API

we instantly see the new branch there.

The command to get all branches is: curl -s -k --header 'PRIVATE-TOKEN:xxx' 'https://gitlab.xxx.com/api/v4/projects/xx/repository/branches'

Does this mean GitLab is somehow caching branch list results or there is some configuration we need to apply in order to get the new branch instantly after creation?

The problem doesn't seem to be happening on another self-hosted instance of GitLab Community Edition v13.6.4 where all projects are set to "Public".

I am not sure if there is a fault in my setup or GitLab itself. Any help is greatly appreciated.

feedy
  • 1,071
  • 5
  • 17

1 Answers1

0

I ran into the same issue. There was a requirement to avoid cloning the repo because it's huge. The only workaround I could come up with was to use git ls-remote command instead of the API:

git ls-remote <git_project_url> refs/heads/*
  • Thanks! I am not part of the project anymore and can't confirm if this works or not, but it's good to know something's wrong on github's api side. – feedy Jan 16 '23 at 12:42