Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab-ce 12.X : how do I find the hashed storage path of a repository on the server?

With gitlab-ce-12.x, Geo requires the storage path to be hashed (https://docs.gitlab.com/ee/administration/repository_storage_types.html)

For a given repository, the data will therefore be stored in : "@hashed/#{hash[0..1]}/#{hash[2..3]}/#{hash}.git"

From a practical point of view, say I have a repository whose URL is

https://my-gitlab-server/Group1/project1.git

How do I work out the path to the storage on the server ? i.e. how do i find the value of

#{hash[0..1]}/#{hash[2..3]}/#{hash}

Thanks

like image 861
iclman Avatar asked Jul 28 '19 15:07

iclman


People also ask

Where does GitLab store repository data?

By default, Omnibus GitLab stores the Git repository data under /var/opt/gitlab/git-data . The repositories are stored in a subfolder called repositories .

What is hashed storage in GitLab?

Hashed Storage is the new storage behavior we rolled out with 10.0. Instead of coupling project URL and the folder structure where the repository will be stored on disk, we are coupling a hash, based on the project's ID.

What is a GitLab path?

In gitlab. yml , you indicate the path for the repositories, for example /home/git/repositories. In Omnibus GitLab configuration you indicate git_data_dirs , which could be /home/git for example. Then Omnibus GitLab creates a repositories directory under that path to use with gitlab.

Where are repos stored?

Within a repository, Git maintains two primary data structures, the object store and the index. All of this repository data is stored at the root of your working directory in a hidden subdirectory named . git.


1 Answers

I found the answer to my question.

In order to get the hashed storage location of a project, you first need to get the project id of the project repository.

Once you get that project id, say your project id is 1, you get the hash this way :

Say project.id is 1

echo -n 1 | sha256sum

=> You get the HASH 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b

The hashed storage location of your repository on the server will therefore be :

server/@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git

This has been discussed by gitlab developers in https://gitlab.com/gitlab-org/gitlab-ce/issues/63250

like image 174
iclman Avatar answered Oct 02 '22 11:10

iclman