From e719c846bbf0b0df1beb9b4fef7fe2824b61a859 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@debian.org>
Date: Tue, 30 Jun 2020 12:06:54 -0400
Subject: [PATCH] add migration howto to gitlab

---
 howto/gitlab.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/howto/gitlab.md b/howto/gitlab.md
index 3162496d..be23e84a 100644
--- a/howto/gitlab.md
+++ b/howto/gitlab.md
@@ -109,6 +109,95 @@ which look like a styled, curly, and closing quotation mark `”`.
 
 # How-to
 
+## How to migrate a Git repository from legacy to GitLab?
+
+Important: this policy is still being debated. It is not clear if any
+or all repositories should be migrated to GitLab, see [issue 36][]
+for the discussion on this topic.
+
+As an example of a repository migration, I have moved the wiki from
+gitolite to gitlab just now. I have followed the following procedure:
+
+ 1. create a project on gitlab (in `tpo/tpa/wiki-archive` in my case)
+
+ 2. push (manually) the latest git references present on `git-rw` to
+    gitlab (`git push --mirror`...)
+
+ 3. if the repository is to be archived on GitLab, make it so in
+    `Settings` -> `General` -> `Advanced` -> `Archive project`
+
+ 4. make an (executable) `pre-receive` hook in `git-rw` with an exit
+    status of `1` warning about the new code location, example:
+
+        $ cat /srv/git.torproject.org/repositories/project/help/wiki.git/hooks/pre-receive 
+        #!/bin/sh
+
+        cat <<EOF
+        This repository has been migrated to GitLab:
+
+        https://gitlab.torproject.org/tpo/tpa/services/-/wikis/home
+
+        Update your remotes to:
+
+            git@gitlab.torproject.org:tpo/tpa/services.wiki.git
+
+        or:
+
+            https://gitlab.torproject.org/tpo/tpa/services.wiki.git
+
+        See this issue for details:
+
+        https://gitlab.torproject.org/tpo/tpa/services/-/issues/34437
+        EOF
+
+        exit 1
+
+    or in the case of a fully archived repository (non-writable):
+    
+        $ cat /srv/git.torproject.org/repositories/project/help/infra.git/hooks/pre-receive 
+        #!/bin/sh
+
+        cat <<EOF
+        This repository has been migrated to GitLab:
+
+        https://gitlab.torproject.org/tpo/tpa/wiki-infra-archive
+
+        We have migrated away from ikiwiki so it is not necessary anymore.
+
+        See this issue for details:
+
+        https://gitlab.torproject.org/tpo/tpa/services/-/issues/34437
+        EOF
+
+        exit 1
+
+ 4. in Gitolite, make the project part of the "Attic", for example
+
+        @@ -328,13 +328,13 @@ admin/trac/TracAccountManager "The Tor Project" = "Tor specific changes to Matth
+         
+         repo project/help/infra
+             RW+                                      = @torproject-admin
+        -    config gitweb.category                   = Infrastructure and Administration
+        -project/help/infra "The Tor Project" = "help.torproject.org infrastructure"
+        +    config gitweb.category                   = Attic
+        +project/help/infra "The Tor Project" = "help.torproject.org infrastructure (archived to GitLab: https://gitlab.torproject.org/tpo/tpa/wiki-infra-archive')"
+         
+         repo project/help/wiki
+             RW                                       = anarcat
+        -    config gitweb.category                   = Infrastructure and Administration
+        -project/help/wiki "The Tor Project" = "help.torproject.org content"
+        +    config gitweb.category                   = Attic
+        +project/help/wiki "The Tor Project" = "help.torproject.org content (archived to GitLab: https://gitlab.torproject.org/tpo/tpa/wiki-archive')"
+         
+         repo project/jenkins/jobs
+             RW                                       = @jenkins-admins
+
+The only downside with that approach is that a git clone will not warn
+about the project redirection, but I am not sure there's a way to fix
+that.
+
+See [issue 36][] for further discussion.
+
 ## How to find the right emoji?
 
 It's possible to add "reaction emojis" to comments and issues and
-- 
GitLab