Perforce Public Knowledge Base - Migrating Repos from Git Fusion to Helix4Git
× PRODUCTS SOLUTIONS CUSTOMERS LEARN SUPPORT
Downloads Blog Company Integrations Careers Contact Try Free
Menu Search
Perforce
Reset Search
 

 

Article

Migrating Repos from Git Fusion to Helix4Git

« Go Back

Information

 
Problem
In order to migrate repos from Git Fusion to Helix4Git the following actions will need to be taken:
  • Create a depot of type graph
  • Create a repo
  • Give gconn-user admin privileges on the graph depot
  • Give permissions to users or groups for the repos
  • Change the Git Fusion repos to read-only
  • Clone the repos from Git Fusion
  • Push repos into Helix4Git graph depot using either ssh or https and the Helix4Git Git Connector
Solution

Migrating Repos from Git Fusion to Helix4Git

Please note:  The Git Fusion preflight commit hooks are not migrated to the Git Connector at this time.  However, if  configuring one-way mirroring using GitLab, you will be able to add custom hooks.

Create a graph depot:

      p4 depot -t graph <graphDepotName>
p4 depot -t graph graphs
Depot graphs saved.

Create script to create repos based on Git Fusion repos:

p4 files -e //.git-fusion/repos/.../p4gf_config | sed 's://.git-fusion/repos/:p4 repo -o //graphs/:' | sed 's:/p4gf.*$: | p4 repo -i:' > createRepos

Create repos by running the script:  createRepos

 p4 repo < repo>
createRepos
Repo //graphs/repo1 saved.
Repo //graphs/repo2 saved.
...

Grant gconn-user admin permissions

p4 grant-permission -u gconn-user -d graphs -p admin
//graphs/... * user gconn-user admin

Grant access to users or groups for the repos:

Helix classic protections do not apply to Helix4Git. Helix4Git permissions will need to be created.

Create the group(s)

You can create separate groups for access to specific repos.
p4 group <group>
p4 group Helix4GitDevs
Group Helix4GitDevs created.

Grant permissions(s)

The write-all grants the following permissions:
the user/group can update the ref, (branch or tag) and all files specified by '-r'.
Also grants 'read' and 'write-ref' permission.
p4 grant-permission -g Helix4GitDevs -d graphs -p write-all
//graphs/... * group Helix4GitDevs write-all

Copy the SSH keys

The ssh keys will need to be copied from //.git-fusion/users/<user>/keys/ and be added to db.pubkey. 
The Git Connector has a cron job configured to read the db.pubkey and add these keys to git's .ssh/authorized_keys file.
 
The keys can be unloaded from Git Fusion and loaded into db.pubkey using the following script:
#!/bin/bash

users=`p4 files //.git-fusion/users/*/keys/... | sed 's://.git-fusion/users/::' | sed 's:keys/::' | sed 's:#.*::' | cut -f 1 -d '/' |  sort -u`

for user in $users; do

        key_count=0

        keys=`p4 files //.git-fusion/users/${user}/keys/... | sed 's://.git-fusion/users/::' | sed 's:keys/::' | sed 's:#.*::' | cut -f 2 -d '/' |  sort -u`

        for key in $keys; do

                key_count=$(( $key_count + 1 ))

                echo "Adding p4 pubkey:  p4 pubkey -i -u $user -s key_${key_count} < ${user}_key_${key}.txt"
                p4 print -q -o ${user}_${key}.txt //.git-fusion/users/$user/keys/$key
                p4 pubkey -i -u $user -s key_${key_count} < ${user}_${key}.txt

        done

        p4 -ztag pubkeys -u $user | grep 'user\|scope'
done


Change Git Fusion to be Read-Only

To set the Git Fusion instance to read-only:  On the Git Fusion server, update  ~/git/p4gf_environment.cfg and add the following setting:  READ_ONLY=true
To set a specific Git Fusion repo to read-only, update the //.git-fusion/repos/<repo>/p4gf_config and add setting under the [@repo] section:  read-only=yes

Clone the Repos from Git Fusion

Create the commands to clone each repo. 
p4 files -e //.git-fusion/repos/.../p4gf_config | sed 's#//.git-fusion/repos/#git clone git@<gitFusionHost>:#' | sed 's#/p4gf.*$##' > cloneRepos
Modify the cloneRepos file to replace <gitFusionHost> with the name of your Git Fusion instance
Run cloneRepos to clone each repo from Git Fusion
 

Create 'git remote' to the Helix4Git Connector for each Helix4Git Graph Depot repo

To view the Helix4Git Connectors set up for the Helix server:
p4 servers | grep git-connector
After each repo is cloned, you can follow these steps to push each repo into Helix4Git
cd <repo>
Add the remote for the Helix4Git Connector (using SSH)
git remote add Helix4Git git@gitConnectorHost:<graphDepot>/<repo>
Verify the remote was successfully created by running: 
git remote -v

Setup branch tracking by running: 

for remote in `git branch -r | grep -v master `; do git checkout --track remotes/$remote ; done

Verify each branch is now local and the branches count matches the remote branch count: 

git branch | wc -l; git branch -r | grep -v HEAD | wc -l;
 

Push all branches of the repo to the Git Connector

git push Helix4Git --all

Push all of the tags of the repo to the Git Connector

git push Helix4Git --tags

OR

Push branches and tags of the repo to the Git Connector

git push Helix4Git "*:*"

On the Helix server, verify all branches and tags are now in Helix for the specified repo: 

p4 graph show-ref -n //<graphDepot>/<repo> 

 

 
   

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255