是否有方法将SourceGear Vault导入/导出到Git

a14dhokn  于 2023-03-11  发布在  Git
关注(0)|答案(2)|浏览(100)

我有一个使用SourceGear Vault的源代码控制系统。
我正在玩Git,想看看我是否能把我的SourceGear回收库放到Git中。
我看不出有什么办法能做到这一点。
有谁能推荐一种方法吗?
我发现了一个文件夹导出/导入工具,创建一个VFE文件扩展名。

klh5stk1

klh5stk11#

看起来没有工具可以做到这一点,除非我自己写!http://support.sourcegear.com/viewtopic.php?f=5&t=18994

**更新:**似乎确实有一个带有Vault 2Git的possible solution

pcww981p

pcww981p2#

这是一个老主题,但我在2023年也面临着同样的挑战。前面提到的Vault2Git在我的案例中运行得不好。我在GitHub上使用Ruby的另一个解决方案也遇到了问题。所以我决定创建自己的解决方案。如果其他人需要,请在这里分享。
我刚刚使用了PowerShell和Vault CLC(命令行客户端)。它可以从SourceGear网站免费下载。

$vaultCLCExe = [PATH TO VAULT CLC]
$localRepository = [PATH TO LOCAL GIT REPO]
$vaultRepositoryName = [NAME OF VAULT REPO]

# authenticate in Vault
.$vaultCLCExe -user [VAULT USER] -password [VAULT PASSWORD] -host [VAULT SERVER] -ssl REMEMBERLOGIN -repository $vaultRepositoryName

# set working folder to local git repository
.$vaultCLCExe SETWORKINGFOLDER $ $localRepository
Set-Location $localRepository

# get full history for repository
[xml]$fullVaultRepoHistoryXML = .$vaultCLCExe HISTORY $

# convert it to custom object so it's easier to use it
$history = $fullVaultRepoHistoryXML.vault.history.ChildNodes | % {
    [PSCustomObject]@{
        txid         = [int]$_.txid
        date         = $_.date
        name         = $_.name
        type         = $_.type
        typeName     = $_.typeName
        version      = [int]$_.version
        objverid     = $_.objverid
        user         = $_.user
        actionString = $_.actionString
    }
}

# get root folders
[xml]$folders = .$vaultCLCExe LISTFOLDER $
$allRootFolders = $folders.vault.folder.ChildNodes.name

# get history of root folders
$allRootFoldersHistory = @{}
foreach ($folder in $allRootFolders){
    [xml]$tempF = .$vaultCLCExe VERSIONHISTORY $folder -rowlimit 0
    $allRootFoldersHistory.Add($folder, $tempF)
}

# get check-ins
$txIDs = $history.txid | select -Unique | sort
[xml]$vaultCommits = .$vaultCLCExe VERSIONHISTORY $ 

# process each check-ins
foreach ($id in $txIDs){
    $events = $history | ? {$_.txid -eq $id} 
    $allRootFoldersAffectedInEvents = $events.name | %{($_ -split("/"))[0..1] -join('/')}
    foreach ($folder in $allRootFolders){
        if ($allRootFoldersAffectedInEvents -contains "$folder"){
            $versionHistoryFolder = $allRootFoldersHistory["$folder"]
            if ($versionHistoryFolder.vault.history.ChildNodes.txid -contains $id){
                $folderVersionToGet = $versionHistoryFolder.vault.history.ChildNodes | ? {$_.txid -eq $id}
                $localFolderPath = $folder.Replace("$",$localRepository).Replace("/","\")
                if (Test-Path $localFolderPath) {
                    Get-ChildItem $localFolderPath | Remove-Item -Recurse -Force
                }
                .$vaultCLCExe GETVERSION $folderVersionToGet.version $folder -backup no -merge overwrite -nocloaks -setfiletime checkin -performdeletions removeworkingcopy
            }
        }
    }

    $commit  = $vaultCommits.vault.history.ChildNodes | ? {$_.txid -eq $id}
    $date    = $commit.date
    $user    = $commit.user
    $comment = $commit.comment
    git add -A
    git commit -m "$comment" --date=$date --author="$user <$user@test.com>"
}

# log off vault
.$vaultCLCExe FORGETLOGIN

相关问题