How do I install Gitlab to run on a Subgit repository?
Asked Answered
P

1

6

I'm just getting started with SubGit and would like to use Gitlab in conjunction.

How would I go about using the Git repository provided by SubGit?

Paling answered 30/1, 2015 at 13:28 Comment(0)
S
5

Follow these instructions in order to use SubGit for GitLab-managed repositories:

  1. Create empty Git repository in GitLab;
  2. On the GitLab server, navigate to the repository directory:

    For a manual install the path is /home/git/repositories/<group>/<project.git>

    For Omnibus installs the path is /var/opt/gitlab/git-data/repositories/<group>/<project.git>

  3. Configure SubGit mirror for created repository:

    $ subgit configure --svn-url <url> <project.git>
    
  4. Adjust configuration file: specify branches and tags mappings, etc.

    $ edit <project.git>/subgit/config
    
  5. Adjust authors mapping file:

    $ edit <project.git>/subgit/authors.txt
    
  6. Specify credentials to be used against SVN server:

    $ edit <project.git>/subgit/passwd
    
  7. Install SubGit into Git repository:

    $ subgit install <project.git>
    
  8. When initial import is done, go to GitLab repository page and see if imported changes are displayed there. In case repository remains empty, try restarting your GitLab instance as this should refresh internal caches.

Please note that according to documentation, GitLab 7.5+ reserves hooks directory for internal usage and one has to use custom_hooks directory for custom pre-receive and post-receive hooks instead.

subgit install on the other hand generates hooks/pre-receive and hooks/post-receive executable scripts which may break GitLab setup for all repositories hosted by the server.

As result, if you're going to use GitLab 7.5+, I'd recommend to follow these slightly adjusted instructions:

  1.— 6. The same steps as above;

  1. Temporarily move hooks directory to hooks_backup:

    $ mv <project.git>/hooks <project.git>/hooks_backup
    
  2. Install SubGit into Git repository:

    $ subgit install <project.git>
    
  3. Move generated hooks directory to custom_hooks:

    $ mv <project.git>/hooks <project.git>/custom_hooks
    
  4. Finally restore GitLab hooks:

    $ mv <project.git>/hooks_backup <project.git>/hooks
    

    After that GitLab should trigger SubGit hooks on every push and so SubGit is able to synchronize pushed commits with SVN repository.

Subauricular answered 3/2, 2015 at 13:45 Comment(6)
Steps 7-10 if you're using GitLab 7.5+ are no longer needed if you're using the SubGit 3.0.0-EAP builds, as it automatically detects a GitLab installation and places the hooks in the custom_hooks directory for you.Engineer
@Subauricular I'm confused about a few things. do I check out an empty git repo first, then subgit configure, install? After I've done configure, install, how do I push all the commits/files to the new/empty git repo?Cappella
@Cappella you don't need to check out empty git repository for importing/mirroring SVN repository; all the instructions above involve empty Git repository created via GitLab UI. That is, you have to create empty Git repository through GitLab UI, then locate that empty Git repository on the file system and finally run subgit configure, subgit install right on that just created empty Git repository. As soon as you have the import done, you can clone resulted repository anywhere and use it as usually.Subauricular
@Subauricular - so this is right on the gitlab server? I was under the impression I could do this locally on my machine, then push to the remote gitlab repo. I get through the configure/import, and then then install. After that, you're saying I should just clone that local repo that subgit has modified to another place on my file sytem, then remote add (gitlab repo), then push to that gitlab repo?Cappella
I have just looking at point 2 but the repo does not seem to exist. Am I meant to create it with the configure command?Excurvate
@Excurvate I think GitLab has switched to hash-based paths for Git repositories. You can find updated instructions at SubGit documentation: subgit.com/documentation/gitlab.htmlSubauricular

© 2022 - 2024 — McMap. All rights reserved.