5

I have a repository in Serena Dimensions; I need to migrate it to Github. I have figured it out that I need to use git-fast-import, but the issue I am facing is with the metadata of Serena Dimensions repo. How to export the metadata from Serena dimensions?

Note: I have updated the answer below, please upvote if you find it useful.

tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83

2 Answers2

4

Here's the ruby Script

#!/usr/bin/env ruby

$stdout.binmode
$author = ""
$date = ""

require 'spreadsheet'
book = Spreadsheet.open('Metadata.xls')
sheet1 = book.worksheet('Sheet1') # can use an index or worksheet name
sheet1.each 1 do |row|
break if row[2].nil? # if first cell empty
    $author = row[2] + " <email@domain.com>"
break if row[5].nil?
    $date = row[5]
#puts row.join(',') # looks like it calls "to_s" on each cell's Value
end

$marks = []
def convert_dir_to_mark(dir)
if !$marks.include?(dir)
    $marks << dir
end
($marks.index(dir)+1).to_s
end


def convert_dir_to_date(dir)
if dir == 'current'
    return Time.now().to_i
else
    dir = dir.gsub('back_', '')
    (year, month, day) = dir.split('_')
    return Time.local(year, month, day).to_i
end
end

def export_data(string)
print "data #{string.size}\n#{string}"
end

def inline_data(file, code='M', mode='644')
content = File.read(file)
puts "#{code} #{mode} inline #{file}"
export_data(content)
end

def print_export(dir, last_mark)
date = convert_dir_to_date(dir)
mark = convert_dir_to_mark(dir)

puts 'commit refs/heads/master'
puts "mark :#{mark}"
puts "committer #{ $author } #{ date } -0700"
export_data("imported from #{dir}")
puts "from :#{last_mark}" if last_mark

puts 'deleteall'
Dir.glob("**/*").each do |file|
    next if !File.file?(file)
    inline_data(file)
end
mark
end


# Loop through the directories
last_mark = nil
Dir.chdir(ARGV[0]) do
Dir.glob("*").each do |dir|
    next if File.file?(dir)

    # move into the target directory
    Dir.chdir(dir) do
        last_mark = print_export(dir, last_mark)
    end
end
end

I exported my Dimensions metadata into a spreadsheet named 'Metadata.xls'. Then read the data from it and imported into Git by running the script.

tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83
  • Did you succeed with this migration without issues? Any lesson learnt from it worth to share? Thanks – A_Di-Matteo Jan 11 '16 at 22:15
  • Yeah, I succeeded in the migration of the repository. Make sure you get the information about the previous authors and dates of commit correctly, otherwise you will need to carry out the migration multiple times. – tRuEsAtM Feb 11 '16 at 00:23
  • Hi @sameer do you have it still somewhere in history (examples) to share? I believe it will take some time to dive in to both dimensions and git-fast import to get there, hehe :) did you manage to save the history of commits and branches? Thank you in advance. – Ilia Shakitko Jan 27 '17 at 17:43
  • @IliaShakitko The example code is way too long, so posting it as an answer. If it helps, please upvote the question and the mark the answer as the correct one. – tRuEsAtM Jan 28 '17 at 22:29
  • @Sameer, how were you able to generate the Metadata.xls? I have the Dimensions Client but have been unable to figure out how to export the data. – BPaasch May 16 '17 at 16:24
  • @BPaasch I believe the functionality is available with their web client. I do not have access to it as I did that at my previous job. Otherwise, I could have just logged on and got the details for you. But check their web client for sure. – tRuEsAtM May 16 '17 at 16:34
  • @BPaasch Any success? – tRuEsAtM May 17 '17 at 20:53
  • @Sameer, not at all. I was able to log into the web client but didn't find any option that downloaded the metadata for a folder, project, or a stream. – BPaasch May 22 '17 at 14:49
  • @Sameer, Can you specify which versions of Serena Dimensions and git you were running when you performed the export/import above? Do you know of any version limitations on either side? – sajb Jul 08 '19 at 13:57
  • @sajb sorry, I don't recall the version numbers and I don't have access to that info now. – tRuEsAtM Jul 18 '19 at 18:51
3

There is also another way to do this - using Git SVN and CM SVN Bridge. With such approach you should be able to use git client to access Dimensions server.
Check this link for details: CM 14.2 New feature: Using a Git Client to access a CM server
Also this thread on Serena forum may be useful: Migrate Dimension repo to git

Update

There is new feature in 14.3.3 which allows to do it much simpler.

Chupik
  • 1,040
  • 8
  • 13
  • 1
    Unfortunately that link to CM 14.2 New feature doesn't work (anymore) – Juergen Aug 17 '17 at 13:53
  • Yes, looks like that page disappeared. But since then new possibilities emerged, for example Dimensions CM Git Connector could be used for that purposes. https://www.serenacentral.com/blogs/entry/dimensions-cm-git-connector-getting-started-tutorial http://help.serena.com/doc_center/cm/ver1433/dmcm_git_connector_guide.pdf – Chupik Aug 17 '17 at 15:00