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.
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 protected]>"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With