Git Import/Export

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Git Import/Export

Post by jchannon » Wed May 23, 2012 6:56 am

First of all may I say, we like SourceGear and we get on with it well.

Just to keep the cogs turning over we're looking at Git as a fun thing to learn and no intent to move to it however we would like to see what our source code would look like in Git. Is there any way to export to Git or import to Git from a SourceGear repository?

Thanks

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Wed May 23, 2012 7:55 am

SourceGear doesn't have an export tool from Vault to Git. You could do a GET from Vault and add those files to Git.

BTW -- If you're looking to experiment with distributed version control, you may want to try SourceGear's Veracity:

http://veracity-scm.com/
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Wed May 23, 2012 7:58 am

A GET? Do you mean Get Latest Version?

Is there anyway to include commit history?

I'm guessing you allow export from Vault to Veracity?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Wed May 23, 2012 8:37 am

SourceGear Vault has a folder export tool, but it only works to export files and history from one Vault repository to another.

If you wanted to get historical versions of files/folders, you could write something that uses the Command Line Client or Client API. Using the GETVERSION command, you could get Version 1, then get Version 2, etc to disk.

Then use tools from the other source control system to commit each version to that source control system.
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Wed May 23, 2012 9:04 am

That's a real shame.

Surprised you have no export tools.

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Thu May 24, 2012 5:40 am

Is it possible to use the API against a backup somehow as not sure how safe doing a GET over every file in the live repo is?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Thu May 24, 2012 8:13 am

GET shouldn't affect the repository. However, if you don't want to do this on your production server, you could restore a copy of the sgvault and sgmaster databases to a test machine, install Vault Server and use the Vault GUI Client, Command Line Client or Client API to do the GET.
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Thu May 24, 2012 8:29 am

Thanks.

I'm now having issues with my VS project. Its not copying the SourceGear API DLL's locally to my debug folder. Any ideas?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Thu May 24, 2012 8:40 am

I could use more details on what you're trying to do.

Is the VS project related to doing a GET from Vault?
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Thu May 24, 2012 9:24 am

I have got a bit further but now I get this error message:

You are attempting to connect to a Vault Standard Server with a Vault Professional client. Please download the correct client from http://sourcegear.com/vault/downloads.html

Here is the code:

Code: Select all

 string url = "https://devserver.mydomain.com:8888/VaultService";
            string username = "jonathan.channon";
            string password = "mypwd";
            string repository = "MyRepository";

            // Set the login options and login/connect to a repository.
            ServerOperations.client.LoginOptions.URL = url;
            ServerOperations.client.LoginOptions.User = username;
            ServerOperations.client.LoginOptions.Password = password;
            ServerOperations.client.LoginOptions.Repository = repository;
            ServerOperations.Login();

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Thu May 24, 2012 9:34 am

I now have it working from downloading the API from http://www.sourcegear.com/vault/downloads.html rather than http://www.sourcegear.com/downloads.html

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Thu May 24, 2012 3:13 pm

Thanks for the update. Yes, it looks like you were using the VaultPro API rather than the Vault Standard API.
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Fri May 25, 2012 4:35 am

This whole project is starting to scare me, trying to use your API to then commit history and files to Git.

Anyhow, I'm not sure the best way to aprroach it. Our SG repo is not constant in its commits, a file might get checked in, a group of files may get checked, labels might/might not get applied to a file or groups of files.

Any ideas on the best way to go?

I'm wondering if the best way is to just loop over every file in the repo, get its history and for each item in the history do a GET on that version and then commit that file version and any label to Git so it has the commit messages and file differences.

One issue is that the ProcessCommandGetVersion wants an int but the VaultHistoryItem has a long for its version number. However I'm unsure what ProcessCommandGetVersion does. Does it overwrite/create that file in the filesystem with that version?

Also, is there a way to get the actual filesystem path from a VaultClientFile?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Git Import/Export

Post by lbauer » Fri May 25, 2012 12:59 pm

The ClientIntegration library is a wrapper. Using the version of the item is correct. For a sample, look at the CLC code for Command.GETVERSION.
"Also, is there a way to get the actual filesystem path from a VaultClientFile?"
VaultClientFile.FullPath will give you the repository's path.

ServerOperations.client.ClientInstance.TreeCache.GetBestWorkingFolder(VaultClientFile.Parent)
should return the current logged in user's configured working folder on disk.
Linda Bauer
SourceGear
Technical Support Manager

jchannon
Posts: 13
Joined: Wed May 23, 2012 6:52 am

Re: Git Import/Export

Post by jchannon » Fri Jun 01, 2012 2:32 am

I have found https://github.com/AndreyNikiforov/vault2git to export Vault to Git however it is very slow.

I have discovered its the SourceGear API. Is there anyway to speed this up?

I must say I'm very disappointed with SourceGear. We use your product with great success but I feel we're trapped now.

Post Reply