ruby - 如何将版本历史从 Serena Dimensions 导出到 Git?

标签 ruby git serena

我在 Serena Dimensions 中有一个存储库;我需要将它迁移到 Github。我发现我需要使用 git-fast-import,但我面临的问题是 Serena Dimensions 存储库的元数据。如何从 Serena 维度导出元数据?

注意:我已经更新了下面的答案,如果觉得有用请点赞。

最佳答案

这是 ruby 脚本

#!/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

我将 Dimensions 元数据导出到名为“Metadata.xls”的电子表格中。然后从中读取数据并通过运行脚本导入到 Git 中。

关于ruby - 如何将版本历史从 Serena Dimensions 导出到 Git?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31301399/

相关文章:

git - Netbeans:加载现有的克隆 GIT 存储库

java - RAD 7.5 的 Serena Dimensions 插件

release-management - 在线用户指南、维基或文档上是否有任何 Serena Dimensions CM?

ruby - 加载错误 : cannot load such file -- data_mapper Why?

使用 % 和 LIKE 在 Rails 中进行 SQL 查询

git - 如果在没有 git-svn 的情况下使用 SVN 和 Git 之间的共享存储库,会有什么问题吗?

git - Octopus merge : cosmetic, 还是某些情况下必不可少?

linux - 致命 : Unable to run checkout callout dimension;jenkins in linux env

ruby-on-rails - 如何取消设置 Ruby/ROR 中的变量?

ruby - Ruby 中的深层嵌套哈希差异