Gitlab tutorial

Hi,

I am working through the tutorial for using subgit with GitLab.

https://subgit.com/documentation/gitlab.html#mirror

I have got to 2.3 and ….

This folder exists:

/var/opt/gitlab/git-data/repositories/

and it goes as deep as:

/var/opt/gitlab/git-data/repositories/@hashed/6b/86

I create the sha1 for the project ID which is 3, which gives:

echo -n 3 | sha256sum
4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce

So I was expecting a directory:

/var/opt/gitlab/git-data/repositories/@hashed/6b/86/4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.git

But that directory does exist. There is one directory but it corresponds to the SHA1 of a project ID of 1.

Am I supposed to create a git repo which matches the SHA1 of the project ID of 3 or am I just supposed to use the one that exists which matches the SHA1 of the project ID of 1?

EDIT:

I tried just running:

subgit configure --svn-url https://svn.domain.local:port/svn/reponame 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.git

To see whether that accurately set up the repo. Everything seemed work but I do not get the line:

Git repository is served by GitLab, hooks will be installed into ‘custom_hooks’ directory.

Which the tutorial says to check for. There is also no entry for [hooks] in the config file.

Hello Steven

GitLab takes two first bytes of the SHA256 hash of the repository number and creates two intermediate directories in the hashed storage. So, if the repository number is 1 and its hash is 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b, then the path would be

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

SHA256 of the number “3” is indeed 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce and thus those intermediate directories called 4e and 07:

@hashed/4e/07/4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.git

You can also find a particular repository path in the GitLab UI:

Admin Area - Overview - Projects - <Select needed project> - Gitaly relative path

In GitLab environment SubGit is supposed to use GitLab repositories instead of creating now ones, so it’s expected that there was no ‘custom_hooks’ directory as the command you used:

subgit configure --svn-url https://svn.domain.local:port/svn/reponame 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.git

actually created a new repository instead of using GitLab’s, so SubGit didn’t recognise GitLab environment.

Great, thank.

I do not seem to have the directory:

@hashed/ 4e

Even though the project exists in GitLab.

Is there something else I need to do?

Try to check repository path in GitLab UI.

The GitLab GUI seems to think that the repo is at:

@hashed/4e/07/4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce.git

But there is nothing there.

There have not been any commits to it yet, does that mean it won’t exist yet?

no, project directories (there are two of them, actually) are being created immediately when you create a project in GitLab UI. Try to create another project to see if it works; also, it worth to check if your GitLab is set to use hashed storage and not the legacy storage:

https://docs.gitlab.com/ee/administration/repository_storage_types.html

Sorted - it was just in a funny directory

I have run the configuration command. I have a complex config file which I have hacked together over the passed few weeks.

Is the only difference to running it without GitLab being detected the addition of the hooks entry in the config file?

If so, then I can copy my previous file over and add that entry in. Otherwise I will need to compare them over the command prompt which will be a pain!

The main difference in the configuration file is the hooks directory setting, yes, so you can use the old configuration file adding that hooks setting.

1 Like